From 842a24899343b7e97ad2dcbab0c057c21f227ae6 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 09:41:43 +0100 Subject: [PATCH 01/30] =?UTF-8?q?=F0=9F=94=84=20-=20Rename=20deuterium=20f?= =?UTF-8?q?uel=20fraction=20variable=20to=20f=5Fplasma=5Ffuel=5Fdeuterium?= =?UTF-8?q?=20across=20the=20codebase=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fusion_reactions/plasma_reactions.md | 2 +- .../physics-models/plasma_composition.md | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/constraints.py | 6 +-- process/data_structure/numerics.py | 2 +- process/data_structure/physics_variables.py | 6 +-- process/fusion_reactions.py | 42 +++++++++++++------ process/init.py | 4 +- process/input.py | 2 +- process/io/obsolete_vars.py | 2 +- process/io/plot_proc.py | 2 +- process/physics.py | 12 +++--- process/physics_functions.py | 2 +- process/stellarator.py | 15 +++---- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/test_fusion_reactions.py | 14 ++++--- tests/unit/test_neoclassics.py | 8 ++-- tests/unit/test_physics.py | 10 +++-- 19 files changed, 81 insertions(+), 56 deletions(-) diff --git a/documentation/physics-models/fusion_reactions/plasma_reactions.md b/documentation/physics-models/fusion_reactions/plasma_reactions.md index c95515085c..905b35f943 100644 --- a/documentation/physics-models/fusion_reactions/plasma_reactions.md +++ b/documentation/physics-models/fusion_reactions/plasma_reactions.md @@ -55,7 +55,7 @@ profiles ## Setting of plasma fuel composition The fractional composition of the 'fuel' ions ($\text{D}$, $\text{T}$ and $^3\text{He}$) is -controlled using the three variables `f_deuterium`, `f_tritium` and `f_helium3`, respectively. +controlled using the three variables `f_plasma_fuel_deuterium`, `f_tritium` and `f_helium3`, respectively. More information about setting seeded impurities and simulating first wall sputtering can be found in the [composition and impurities section](../plasma_composition.md). It is also possible to optimise on the deuterium-tritium fuel mixture ratio. For this, `f_tritium` **must** be set as an iteration variable with `ixc = 173`. More info can be found [here](#fuel-ions-mixture-self-consistency). diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index 1b6a9faf0d..1574b31953 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -36,7 +36,7 @@ using input array `f_nd_impurity_electrons(1,...,14)`. The available species alo As stated above, the number density fractions for hydrogen (all isotopes) and helium should not be set, as they are calculated by the code. This is to ensure plasma quasi-neutrality taking into account the fuel ratios -`f_deuterium`, `f_tritium` and `f_helium3`, and the alpha particle fraction `f_nd_alpha_electron` which may +`f_plasma_fuel_deuterium`, `f_tritium` and `f_helium3`, and the alpha particle fraction `f_nd_alpha_electron` which may be input by the user or selected as an iteration variable. !!! note "Location of impurities" diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 9d375f7dbf..cb1d9bae38 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -284,7 +284,7 @@ Greenwald_model__________________________________________________________ (dlimit(7))____________________ 7.20274886424344904e+19 OP ASDEX_New________________________________________________________________ (dlimit(8))____________________ 8.37005006999513989e+20 OP Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.20274886424344904e+19 OP - Deuterium_fuel_fraction__________________________________________________ (f_deuterium)__________________ 5.00000000000000000e-01 + Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_tritium)____________________ 5.00000000000000000e-01 3-Helium_fuel_fraction___________________________________________________ (f_helium3)____________________ 0.00000000000000000e+00 Total_fusion_power_(MW)__________________________________________________ (p_fusion_total_mw)_________________ 1.60956116199862254e+03 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 0e54d8a8a9..1e4fe9ed45 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -357,7 +357,7 @@ ASDEX_New________________________________________________________________ (dlimit(8))____________________ 1.03091554466307611e+21 OP Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.84515075612383478e+19 OP Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*dnelimt)____________ 7.84515075612383478e+19 OP - Deuterium_fuel_fraction__________________________________________________ (f_deuterium)__________________ 5.00000000000000000e-01 + Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_tritium)____________________ 5.00000000000000000e-01 3-Helium_fuel_fraction___________________________________________________ (f_helium3)____________________ 0.00000000000000000e+00 Total_fusion_power_(MW)__________________________________________________ (p_fusion_total_mw)_________________ 1.74333215950657041e+03 OP diff --git a/process/constraints.py b/process/constraints.py index 841ccdcf13..b598896bc4 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -2371,16 +2371,16 @@ def constraint_equation_92(): """Equation for checking is D/T ratio is consistent, and sums to 1. author: G Turkington, UKAEA - f_deuterium: fraction of deuterium ions + f_plasma_fuel_deuterium: fraction of deuterium ions f_tritium: fraction of tritium ions f_helium3: fraction of helium-3 ions """ - f_deuterium = 1.0 - ( + f_plasma_fuel_deuterium = 1.0 - ( data_structure.physics_variables.f_tritium + data_structure.physics_variables.f_helium3 ) cc = 1.0 - ( - f_deuterium + f_plasma_fuel_deuterium + data_structure.physics_variables.f_tritium + data_structure.physics_variables.f_helium3 ) diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index c52ba408e0..a5cfa4ec98 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -368,7 +368,7 @@ * (170) deg_div_field_plate : field line angle wrt divertor target plate (degrees) * (171) casths_fraction : TF side case thickness as fraction of toridal case thickness * (172) dx_tf_side_case_min : TF side case thickness [m] -* (173) f_deuterium : Deuterium fraction in fuel +* (173) f_plasma_fuel_deuterium : Deuterium fraction in fuel * (174) EMPTY : Description * (175) EMPTY : Description """ diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index df27334cf0..742f978410 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -448,7 +448,7 @@ """fraction of alpha power to ions""" -f_deuterium: float = None +f_plasma_fuel_deuterium: float = None """deuterium fuel fraction""" @@ -1431,7 +1431,7 @@ def init_physics_variables(): global f_alpha_electron global f_p_alpha_plasma_deposited global f_alpha_ion - global f_deuterium + global f_plasma_fuel_deuterium global f_p_div_lower global ffwal global f_nd_plasma_pedestal_greenwald @@ -1684,7 +1684,7 @@ def init_physics_variables(): f_alpha_electron = 0.0 f_p_alpha_plasma_deposited = 0.95 f_alpha_ion = 0.0 - f_deuterium = 0.5 + f_plasma_fuel_deuterium = 0.5 f_p_div_lower = 1.0 ffwal = 0.92 f_nd_plasma_pedestal_greenwald = 0.85 diff --git a/process/fusion_reactions.py b/process/fusion_reactions.py index 3953078baa..6c287dae38 100644 --- a/process/fusion_reactions.py +++ b/process/fusion_reactions.py @@ -219,7 +219,7 @@ def dt_reaction(self) -> None: * self.plasma_profile.teprofile.profile_y, dt, ) - * physics_variables.f_deuterium + * physics_variables.f_plasma_fuel_deuterium * physics_variables.f_tritium * ( self.plasma_profile.neprofile.profile_y @@ -248,7 +248,10 @@ def dt_reaction(self) -> None: fusion_power_density = ( sigmav * reaction_energy - * (physics_variables.f_deuterium * physics_variables.nd_fuel_ions) + * ( + physics_variables.f_plasma_fuel_deuterium + * physics_variables.nd_fuel_ions + ) * (physics_variables.f_tritium * physics_variables.nd_fuel_ions) ) @@ -319,7 +322,7 @@ def dhe3_reaction(self) -> None: * self.plasma_profile.teprofile.profile_y, dhe3, ) - * physics_variables.f_deuterium + * physics_variables.f_plasma_fuel_deuterium * physics_variables.f_helium3 * ( self.plasma_profile.neprofile.profile_y @@ -338,7 +341,10 @@ def dhe3_reaction(self) -> None: fusion_power_density = ( sigmav * reaction_energy - * (physics_variables.f_deuterium * physics_variables.nd_fuel_ions) + * ( + physics_variables.f_plasma_fuel_deuterium + * physics_variables.nd_fuel_ions + ) * (physics_variables.f_helium3 * physics_variables.nd_fuel_ions) ) @@ -410,8 +416,8 @@ def dd_helion_reaction(self) -> None: * self.plasma_profile.teprofile.profile_y, dd1, ) - * physics_variables.f_deuterium - * physics_variables.f_deuterium + * physics_variables.f_plasma_fuel_deuterium + * physics_variables.f_plasma_fuel_deuterium * ( self.plasma_profile.neprofile.profile_y * ( @@ -432,8 +438,14 @@ def dd_helion_reaction(self) -> None: sigmav * reaction_energy * (1.0 - self.f_dd_branching_trit) - * (physics_variables.f_deuterium * physics_variables.nd_fuel_ions) - * (physics_variables.f_deuterium * physics_variables.nd_fuel_ions) + * ( + physics_variables.f_plasma_fuel_deuterium + * physics_variables.nd_fuel_ions + ) + * ( + physics_variables.f_plasma_fuel_deuterium + * physics_variables.nd_fuel_ions + ) ) # Power densities for different particles [MW/m^3] @@ -504,8 +516,8 @@ def dd_triton_reaction(self) -> None: * self.plasma_profile.teprofile.profile_y, dd2, ) - * physics_variables.f_deuterium - * physics_variables.f_deuterium + * physics_variables.f_plasma_fuel_deuterium + * physics_variables.f_plasma_fuel_deuterium * ( self.plasma_profile.neprofile.profile_y * ( @@ -526,8 +538,14 @@ def dd_triton_reaction(self) -> None: sigmav * reaction_energy * self.f_dd_branching_trit - * (physics_variables.f_deuterium * physics_variables.nd_fuel_ions) - * (physics_variables.f_deuterium * physics_variables.nd_fuel_ions) + * ( + physics_variables.f_plasma_fuel_deuterium + * physics_variables.nd_fuel_ions + ) + * ( + physics_variables.f_plasma_fuel_deuterium + * physics_variables.nd_fuel_ions + ) ) # Power densities for different particles [MW/m^3] diff --git a/process/init.py b/process/init.py index b4fff3c9d1..72b1e27485 100644 --- a/process/init.py +++ b/process/init.py @@ -368,7 +368,7 @@ def check_process(inputs): # noqa: ARG001 if ( abs( 1.0 - - data_structure.physics_variables.f_deuterium + - data_structure.physics_variables.f_plasma_fuel_deuterium - data_structure.physics_variables.f_tritium - data_structure.physics_variables.f_helium3 ) @@ -376,7 +376,7 @@ def check_process(inputs): # noqa: ARG001 ): raise ProcessValidationError( "Fuel ion fractions do not sum to 1.0", - f_deuterium=data_structure.physics_variables.f_deuterium, + f_plasma_fuel_deuterium=data_structure.physics_variables.f_plasma_fuel_deuterium, f_tritium=data_structure.physics_variables.f_tritium, f_helium3=data_structure.physics_variables.f_helium3, ) diff --git a/process/input.py b/process/input.py index 264f199b15..3a627d96d7 100644 --- a/process/input.py +++ b/process/input.py @@ -159,7 +159,7 @@ def __post_init__(self): "f_p_div_lower": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), - "f_deuterium": InputVariable( + "f_plasma_fuel_deuterium": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), "ffwal": InputVariable(data_structure.physics_variables, float, range=(0.0, 10.0)), diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index f4d918ae50..e1802f9309 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -129,7 +129,7 @@ "vgap": "dz_xpoint_divertor", "ftritbm": "f_tritium_bream", "enbeam": "e_beam_kev", - "fdeut": "f_deuterium", + "fdeut": "f_plasma_fuel_deuterium", "ftrit": "f_tritium", "fhe3": "f_helium3", "falpha": "f_p_alpha_plasma_deposited", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 4ac9e3379d..6f47d28994 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2874,7 +2874,7 @@ def plot_main_plasma_information( textstr_reactions = ( f"$\\mathbf{{Fusion \\ Reactions:}}$\n \n" f"Fuel mixture: \n" - f"| D: {mfile_data.data['f_deuterium'].get_scan(scan):.2f} | T: {mfile_data.data['f_tritium'].get_scan(scan):.2f} | 3He: {mfile_data.data['f_helium3'].get_scan(scan):.2f} |\n\n" + f"| D: {mfile_data.data['f_plasma_fuel_deuterium'].get_scan(scan):.2f} | T: {mfile_data.data['f_tritium'].get_scan(scan):.2f} | 3He: {mfile_data.data['f_helium3'].get_scan(scan):.2f} |\n\n" f"Fusion Power, $P_{{\\text{{fus}}}}:$ {mfile_data.data['p_fusion_total_mw'].get_scan(scan):.2f} MW\n" f"D-T Power, $P_{{\\text{{fus,DT}}}}:$ {mfile_data.data['p_dt_total_mw'].get_scan(scan):.2f} MW\n" f"D-D Power, $P_{{\\text{{fus,DD}}}}:$ {mfile_data.data['p_dd_total_mw'].get_scan(scan):.2f} MW\n" diff --git a/process/physics.py b/process/physics.py index 9d9ab8ec83..3aeabfc2c0 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2206,7 +2206,7 @@ def physics(self): physics_variables.nd_fuel_ions, physics_variables.dlamie, current_drive_variables.e_beam_kev, - physics_variables.f_deuterium, + physics_variables.f_plasma_fuel_deuterium, physics_variables.f_tritium, current_drive_variables.f_beam_tritium, physics_variables.sigmav_dt_average, @@ -3298,7 +3298,7 @@ def plasma_composition() -> None: impurity_radiation.element2index("H_") ] = ( physics_variables.nd_protons - + (physics_variables.f_deuterium + physics_variables.f_tritium) + + (physics_variables.f_plasma_fuel_deuterium + physics_variables.f_tritium) * physics_variables.nd_fuel_ions + physics_variables.nd_beam_ions ) / physics_variables.nd_plasma_electrons_vol_avg @@ -3401,7 +3401,7 @@ def plasma_composition() -> None: # Average atomic masses of injected fuel species physics_variables.m_fuel_amu = ( - (constants.M_DEUTERON_AMU * physics_variables.f_deuterium) + (constants.M_DEUTERON_AMU * physics_variables.f_plasma_fuel_deuterium) + (constants.M_TRITON_AMU * physics_variables.f_tritium) + (constants.M_HELION_AMU * physics_variables.f_helium3) ) @@ -3441,7 +3441,7 @@ def plasma_composition() -> None: # Sum of (Zi^2*n_i) / m_i physics_variables.zeffai = ( ( - physics_variables.f_deuterium + physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_fuel_ions / constants.M_DEUTERON_AMU ) @@ -5060,8 +5060,8 @@ def outplas(self): po.ovarrf( self.outfile, "Deuterium fuel fraction", - "(f_deuterium)", - physics_variables.f_deuterium, + "(f_plasma_fuel_deuterium)", + physics_variables.f_plasma_fuel_deuterium, ) po.ovarrf( self.outfile, diff --git a/process/physics_functions.py b/process/physics_functions.py index 05c6ce4db5..972369e034 100644 --- a/process/physics_functions.py +++ b/process/physics_functions.py @@ -268,7 +268,7 @@ def fast_alpha_beta( """ # Determine average fast alpha density - if physics_variables.f_deuterium < 1.0: + if physics_variables.f_plasma_fuel_deuterium < 1.0: beta_thermal = ( 2.0 * constants.RMU0 diff --git a/process/stellarator.py b/process/stellarator.py index acd0a4bd55..ceb28360dc 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4350,7 +4350,7 @@ def stphys(self, output): physics_variables.nd_fuel_ions, physics_variables.dlamie, current_drive_variables.e_beam_kev, - physics_variables.f_deuterium, + physics_variables.f_plasma_fuel_deuterium, physics_variables.f_tritium, current_drive_variables.f_beam_tritium, physics_variables.sigmav_dt_average, @@ -5408,12 +5408,12 @@ def init_profile_values_from_PROCESS(self, rho): * (1 - rho**2) ** physics_variables.alphan ) densT = ( - (1 - physics_variables.f_deuterium) + (1 - physics_variables.f_plasma_fuel_deuterium) * physics_variables.nd_plasma_ions_on_axis * (1 - rho**2) ** physics_variables.alphan ) densD = ( - physics_variables.f_deuterium + physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_plasma_ions_on_axis * (1 - rho**2) ** physics_variables.alphan ) @@ -5479,7 +5479,7 @@ def init_profile_values_from_PROCESS(self, rho): * 1.0 / physics_variables.rminor * rho - * (1 - physics_variables.f_deuterium) + * (1 - physics_variables.f_plasma_fuel_deuterium) * physics_variables.nd_plasma_ions_on_axis * (1.0 - rho**2) ** (physics_variables.alphan - 1.0) * physics_variables.alphan @@ -5489,7 +5489,7 @@ def init_profile_values_from_PROCESS(self, rho): * 1.0 / physics_variables.rminor * rho - * physics_variables.f_deuterium + * physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_plasma_ions_on_axis * (1.0 - rho**2) ** (physics_variables.alphan - 1.0) * physics_variables.alphan @@ -5630,8 +5630,9 @@ def neoclassics_calc_nu_star_fromT(self, iota): ) density = np.array([ physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_fuel_ions * physics_variables.f_deuterium, - physics_variables.nd_fuel_ions * (1 - physics_variables.f_deuterium), + physics_variables.nd_fuel_ions * physics_variables.f_plasma_fuel_deuterium, + physics_variables.nd_fuel_ions + * (1 - physics_variables.f_plasma_fuel_deuterium), physics_variables.nd_alphas, ]) diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index 2112d6b28a..b703270a8c 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -622,7 +622,7 @@ boundu(28) = 1.0 * DESCRIPTION: Seeded f_nd_protium_electrons density / electron density (default = 0.0) * JUSTIFICATION: Not used, no f_nd_protium_electrons seeding. -*f_deuterium = +*f_plasma_fuel_deuterium = * DESCRIPTION: Deuterium fuel fraction * JUSTIFICATION: Using default = 0.5 diff --git a/tests/unit/test_fusion_reactions.py b/tests/unit/test_fusion_reactions.py index f3bd7d1d45..aa4ba37d55 100644 --- a/tests/unit/test_fusion_reactions.py +++ b/tests/unit/test_fusion_reactions.py @@ -13,7 +13,7 @@ class SetFusionPowersParam(NamedTuple): f_p_alpha_plasma_deposited: Any = None - f_deuterium: Any = None + f_plasma_fuel_deuterium: Any = None i_beta_fast_alpha: Any = None @@ -71,7 +71,7 @@ class SetFusionPowersParam(NamedTuple): ( SetFusionPowersParam( f_p_alpha_plasma_deposited=0.95, - f_deuterium=0.5, + f_plasma_fuel_deuterium=0.5, f_alpha_electron=0.68, f_alpha_ion=0.32, p_beam_alpha_mw=0, @@ -91,7 +91,7 @@ class SetFusionPowersParam(NamedTuple): ), SetFusionPowersParam( f_p_alpha_plasma_deposited=0.95, - f_deuterium=0.5, + f_plasma_fuel_deuterium=0.5, f_alpha_electron=0.68, f_alpha_ion=0.32, p_beam_alpha_mw=100.5, @@ -111,7 +111,7 @@ class SetFusionPowersParam(NamedTuple): ), SetFusionPowersParam( f_p_alpha_plasma_deposited=0.95, - f_deuterium=0.5, + f_plasma_fuel_deuterium=0.5, f_alpha_electron=0.68, f_alpha_ion=0.32, p_beam_alpha_mw=100.5, @@ -131,7 +131,7 @@ class SetFusionPowersParam(NamedTuple): ), SetFusionPowersParam( f_p_alpha_plasma_deposited=0.95, - f_deuterium=2.5, + f_plasma_fuel_deuterium=2.5, f_alpha_electron=0.68, f_alpha_ion=0.32, p_beam_alpha_mw=100.5, @@ -168,7 +168,9 @@ def test_set_fusion_powers(setfusionpowersparam, monkeypatch): "f_p_alpha_plasma_deposited", setfusionpowersparam.f_p_alpha_plasma_deposited, ) - monkeypatch.setattr(pv, "f_deuterium", setfusionpowersparam.f_deuterium) + monkeypatch.setattr( + pv, "f_plasma_fuel_deuterium", setfusionpowersparam.f_plasma_fuel_deuterium + ) ( pden_neutron_total_mw, diff --git a/tests/unit/test_neoclassics.py b/tests/unit/test_neoclassics.py index a96b7999cb..8662f06b40 100644 --- a/tests/unit/test_neoclassics.py +++ b/tests/unit/test_neoclassics.py @@ -24,7 +24,7 @@ class InitNeoclassicsParam(NamedTuple): alphat: Any = None temp_plasma_ion_on_axis_kev: Any = None nd_plasma_ions_on_axis: Any = None - f_deuterium: Any = None + f_plasma_fuel_deuterium: Any = None nd_alphas: Any = None rminor: Any = None rmajor: Any = None @@ -73,7 +73,7 @@ class InitNeoclassicsParam(NamedTuple): alphat=1.2, temp_plasma_ion_on_axis_kev=12.579710000000002, nd_plasma_ions_on_axis=2.3930858160000005e20, - f_deuterium=0.5, + f_plasma_fuel_deuterium=0.5, nd_alphas=2.9820384000000004e19, rminor=1.7993820274145451, rmajor=22.16, @@ -996,7 +996,9 @@ def test_init_neoclassics(initneoclassicsparam, monkeypatch, neoclassics): initneoclassicsparam.nd_plasma_ions_on_axis, ) monkeypatch.setattr( - physics_variables, "f_deuterium", initneoclassicsparam.f_deuterium + physics_variables, + "f_plasma_fuel_deuterium", + initneoclassicsparam.f_plasma_fuel_deuterium, ) monkeypatch.setattr(physics_variables, "nd_alphas", initneoclassicsparam.nd_alphas) monkeypatch.setattr(physics_variables, "rminor", initneoclassicsparam.rminor) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index b391f4bbd9..ecb0d451bb 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1400,7 +1400,7 @@ class PlasmaCompositionParam(NamedTuple): proton_rate_density: Any = None - f_deuterium: Any = None + f_plasma_fuel_deuterium: Any = None alphan: Any = None @@ -1546,7 +1546,7 @@ class PlasmaCompositionParam(NamedTuple): m_beam_amu=0, te=12, proton_rate_density=0, - f_deuterium=0.5, + f_plasma_fuel_deuterium=0.5, alphan=1, nd_beam_ions=0, f_helium3=0, @@ -1664,7 +1664,7 @@ class PlasmaCompositionParam(NamedTuple): m_beam_amu=2.01355414, te=12, proton_rate_density=540072280299564.38, - f_deuterium=0.5, + f_plasma_fuel_deuterium=0.5, alphan=1, nd_beam_ions=0, f_helium3=0, @@ -1855,7 +1855,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "f_deuterium", plasmacompositionparam.f_deuterium + physics_variables, + "f_plasma_fuel_deuterium", + plasmacompositionparam.f_plasma_fuel_deuterium, ) monkeypatch.setattr(physics_variables, "alphan", plasmacompositionparam.alphan) From 972c624a9731d3135dc0319eb99bc5f8c3c438f8 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 09:42:47 +0100 Subject: [PATCH 02/30] =?UTF-8?q?=F0=9F=94=84=20-=20Refactor=20tritium=20v?= =?UTF-8?q?ariable=20naming=20to=20f=5Fplasma=5Ffuel=5Ftritium=20for=20con?= =?UTF-8?q?sistency=20across=20the=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fusion_reactions/plasma_reactions.md | 6 +++--- .../physics-models/plasma_composition.md | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/constraints.py | 6 +++--- process/costs.py | 2 +- process/data_structure/physics_variables.py | 6 +++--- process/fusion_reactions.py | 4 ++-- process/init.py | 6 +++--- process/input.py | 2 +- process/io/obsolete_vars.py | 4 ++-- process/io/plot_proc.py | 2 +- process/iteration_variables.py | 4 +++- process/physics.py | 15 +++++++++------ process/stellarator.py | 2 +- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/test_costs_1990.py | 18 +++++++++++------- tests/unit/test_physics.py | 10 ++++++---- 18 files changed, 53 insertions(+), 42 deletions(-) diff --git a/documentation/physics-models/fusion_reactions/plasma_reactions.md b/documentation/physics-models/fusion_reactions/plasma_reactions.md index 905b35f943..64be033985 100644 --- a/documentation/physics-models/fusion_reactions/plasma_reactions.md +++ b/documentation/physics-models/fusion_reactions/plasma_reactions.md @@ -55,10 +55,10 @@ profiles ## Setting of plasma fuel composition The fractional composition of the 'fuel' ions ($\text{D}$, $\text{T}$ and $^3\text{He}$) is -controlled using the three variables `f_plasma_fuel_deuterium`, `f_tritium` and `f_helium3`, respectively. +controlled using the three variables `f_plasma_fuel_deuterium`, `f_plasma_fuel_tritium` and `f_helium3`, respectively. More information about setting seeded impurities and simulating first wall sputtering can be found in the [composition and impurities section](../plasma_composition.md). -It is also possible to optimise on the deuterium-tritium fuel mixture ratio. For this, `f_tritium` **must** be set as an iteration variable with `ixc = 173`. More info can be found [here](#fuel-ions-mixture-self-consistency). +It is also possible to optimise on the deuterium-tritium fuel mixture ratio. For this, `f_plasma_fuel_tritium` **must** be set as an iteration variable with `ixc = 173`. More info can be found [here](#fuel-ions-mixture-self-consistency). !!! note "Reactions not calculated" @@ -238,7 +238,7 @@ The value of `big_q_plasma_min` can be set to the minimum desired $Q_{\text{plas This constraint can be activated by stating `icc = 92` in the input file. -This constraint should be activated if the user wishes to allow the ratio of the fuel ions to be iterated upon. For this, `f_tritium` has to be set as an iteration variable with `ixc = 173`. This constraint ensure that the summation of the fuel fractions always sums to 1.0 and will modify the other compositions depending on the value of `f_tritium`. +This constraint should be activated if the user wishes to allow the ratio of the fuel ions to be iterated upon. For this, `f_plasma_fuel_tritium` has to be set as an iteration variable with `ixc = 173`. This constraint ensure that the summation of the fuel fractions always sums to 1.0 and will modify the other compositions depending on the value of `f_plasma_fuel_tritium`. [^1]: H.-S. Bosch and G. M. Hale, “Improved formulas for fusion cross-sections and thermal reactivities,” Nuclear Fusion, vol. 32, no. 4, pp. 611–631, Apr. 1992, doi: https://doi.org/10.1088/0029-5515/32/4/i07. [^2]: I. P. E. G. on E. Drive and I. P. B. Editors, “Chapter 5: Physics of energetic ions,” Nuclear Fusion, vol. 39, no. 12, pp. 2471–2495, Dec. 1999, doi: https://doi.org/10.1088/0029-5515/39/12/305. diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index 1574b31953..f96e299d4e 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -36,7 +36,7 @@ using input array `f_nd_impurity_electrons(1,...,14)`. The available species alo As stated above, the number density fractions for hydrogen (all isotopes) and helium should not be set, as they are calculated by the code. This is to ensure plasma quasi-neutrality taking into account the fuel ratios -`f_plasma_fuel_deuterium`, `f_tritium` and `f_helium3`, and the alpha particle fraction `f_nd_alpha_electron` which may +`f_plasma_fuel_deuterium`, `f_plasma_fuel_tritium` and `f_helium3`, and the alpha particle fraction `f_nd_alpha_electron` which may be input by the user or selected as an iteration variable. !!! note "Location of impurities" diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index cb1d9bae38..5d243cca60 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -285,7 +285,7 @@ ASDEX_New________________________________________________________________ (dlimit(8))____________________ 8.37005006999513989e+20 OP Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.20274886424344904e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 - Tritium_fuel_fraction____________________________________________________ (f_tritium)____________________ 5.00000000000000000e-01 + Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 3-Helium_fuel_fraction___________________________________________________ (f_helium3)____________________ 0.00000000000000000e+00 Total_fusion_power_(MW)__________________________________________________ (p_fusion_total_mw)_________________ 1.60956116199862254e+03 OP Fusion_rate_density:_total_(particles/m3/sec)____________________________ (fusden_total)____ 3.03874355943265088e+17 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 1e4fe9ed45..a2007e59cd 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -358,7 +358,7 @@ Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.84515075612383478e+19 OP Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*dnelimt)____________ 7.84515075612383478e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 - Tritium_fuel_fraction____________________________________________________ (f_tritium)____________________ 5.00000000000000000e-01 + Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 3-Helium_fuel_fraction___________________________________________________ (f_helium3)____________________ 0.00000000000000000e+00 Total_fusion_power_(MW)__________________________________________________ (p_fusion_total_mw)_________________ 1.74333215950657041e+03 OP Fusion_rate_density:_total_(particles/m3/sec)____________________________ (fusden_total)____ 3.29182443497713664e+17 OP diff --git a/process/constraints.py b/process/constraints.py index b598896bc4..6d8ee01e46 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -2372,16 +2372,16 @@ def constraint_equation_92(): author: G Turkington, UKAEA f_plasma_fuel_deuterium: fraction of deuterium ions - f_tritium: fraction of tritium ions + f_plasma_fuel_tritium: fraction of tritium ions f_helium3: fraction of helium-3 ions """ f_plasma_fuel_deuterium = 1.0 - ( - data_structure.physics_variables.f_tritium + data_structure.physics_variables.f_plasma_fuel_tritium + data_structure.physics_variables.f_helium3 ) cc = 1.0 - ( f_plasma_fuel_deuterium - + data_structure.physics_variables.f_tritium + + data_structure.physics_variables.f_plasma_fuel_tritium + data_structure.physics_variables.f_helium3 ) diff --git a/process/costs.py b/process/costs.py index 07f5e41258..532482694f 100644 --- a/process/costs.py +++ b/process/costs.py @@ -2491,7 +2491,7 @@ def acc2273(self): cfrht = 1.0e5 # No detritiation needed if purely D-He3 reaction - if physics_variables.f_tritium > 1.0e-3: + if physics_variables.f_plasma_fuel_tritium > 1.0e-3: cost_variables.c2273 = ( 1.0e-6 * cost_variables.UCDTC diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 742f978410..98cdd89398 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -504,7 +504,7 @@ """ -f_tritium: float = None +f_plasma_fuel_tritium: float = None """tritium fuel fraction""" @@ -1442,7 +1442,7 @@ def init_physics_variables(): global fplhsep global fp_plasma_separatrix_min_mw global fne0 - global f_tritium + global f_plasma_fuel_tritium global fusden_total global fusrat_total global fusrat_plasma_dt_profile @@ -1695,7 +1695,7 @@ def init_physics_variables(): fplhsep = 1.0 fp_plasma_separatrix_min_mw = 1.0 fne0 = 1.0 - f_tritium = 0.5 + f_plasma_fuel_tritium = 0.5 fusden_total = 0.0 fusrat_total = 0.0 fusrat_plasma_dt_profile = [] diff --git a/process/fusion_reactions.py b/process/fusion_reactions.py index 6c287dae38..8dbfa344ca 100644 --- a/process/fusion_reactions.py +++ b/process/fusion_reactions.py @@ -220,7 +220,7 @@ def dt_reaction(self) -> None: dt, ) * physics_variables.f_plasma_fuel_deuterium - * physics_variables.f_tritium + * physics_variables.f_plasma_fuel_tritium * ( self.plasma_profile.neprofile.profile_y * ( @@ -252,7 +252,7 @@ def dt_reaction(self) -> None: physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_fuel_ions ) - * (physics_variables.f_tritium * physics_variables.nd_fuel_ions) + * (physics_variables.f_plasma_fuel_tritium * physics_variables.nd_fuel_ions) ) # Power densities for different particles [MW/m^3] diff --git a/process/init.py b/process/init.py index 72b1e27485..65dc6cf598 100644 --- a/process/init.py +++ b/process/init.py @@ -369,7 +369,7 @@ def check_process(inputs): # noqa: ARG001 abs( 1.0 - data_structure.physics_variables.f_plasma_fuel_deuterium - - data_structure.physics_variables.f_tritium + - data_structure.physics_variables.f_plasma_fuel_tritium - data_structure.physics_variables.f_helium3 ) > 1e-6 @@ -377,12 +377,12 @@ def check_process(inputs): # noqa: ARG001 raise ProcessValidationError( "Fuel ion fractions do not sum to 1.0", f_plasma_fuel_deuterium=data_structure.physics_variables.f_plasma_fuel_deuterium, - f_tritium=data_structure.physics_variables.f_tritium, + f_plasma_fuel_tritium=data_structure.physics_variables.f_plasma_fuel_tritium, f_helium3=data_structure.physics_variables.f_helium3, ) if ( - data_structure.physics_variables.f_tritium < 1.0e-3 + data_structure.physics_variables.f_plasma_fuel_tritium < 1.0e-3 ): # tritium fraction is negligible data_structure.buildings_variables.triv = 0.0 data_structure.heat_transport_variables.p_tritium_plant_electric_mw = 0.0 diff --git a/process/input.py b/process/input.py index 3a627d96d7..d7af843535 100644 --- a/process/input.py +++ b/process/input.py @@ -716,7 +716,7 @@ def __post_init__(self): "f_t_turn_tf": InputVariable( data_structure.tfcoil_variables, float, range=(0.0, 1.0) ), - "f_tritium": InputVariable( + "f_plasma_fuel_tritium": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), "f_beam_tritium": InputVariable( diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index e1802f9309..27badf3118 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -101,7 +101,7 @@ "sigvvall": "max_vv_stress", "ftaucq": "fmaxvvstress", "fradmin": None, - "ftr": "f_tritium", + "ftr": "f_plasma_fuel_tritium", "iculdl": "idensl", "iiter": None, "ires": None, @@ -130,7 +130,7 @@ "ftritbm": "f_tritium_bream", "enbeam": "e_beam_kev", "fdeut": "f_plasma_fuel_deuterium", - "ftrit": "f_tritium", + "ftrit": "f_plasma_fuel_tritium", "fhe3": "f_helium3", "falpha": "f_p_alpha_plasma_deposited", "idensl": "i_density_limit", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 6f47d28994..58b1fe11d8 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2874,7 +2874,7 @@ def plot_main_plasma_information( textstr_reactions = ( f"$\\mathbf{{Fusion \\ Reactions:}}$\n \n" f"Fuel mixture: \n" - f"| D: {mfile_data.data['f_plasma_fuel_deuterium'].get_scan(scan):.2f} | T: {mfile_data.data['f_tritium'].get_scan(scan):.2f} | 3He: {mfile_data.data['f_helium3'].get_scan(scan):.2f} |\n\n" + f"| D: {mfile_data.data['f_plasma_fuel_deuterium'].get_scan(scan):.2f} | T: {mfile_data.data['f_plasma_fuel_tritium'].get_scan(scan):.2f} | 3He: {mfile_data.data['f_helium3'].get_scan(scan):.2f} |\n\n" f"Fusion Power, $P_{{\\text{{fus}}}}:$ {mfile_data.data['p_fusion_total_mw'].get_scan(scan):.2f} MW\n" f"D-T Power, $P_{{\\text{{fus,DT}}}}:$ {mfile_data.data['p_dt_total_mw'].get_scan(scan):.2f} MW\n" f"D-D Power, $P_{{\\text{{fus,DD}}}}:$ {mfile_data.data['p_dd_total_mw'].get_scan(scan):.2f} MW\n" diff --git a/process/iteration_variables.py b/process/iteration_variables.py index 6880205110..e4a6bc7cfd 100644 --- a/process/iteration_variables.py +++ b/process/iteration_variables.py @@ -424,7 +424,9 @@ class IterationVariable: 172: IterationVariable( "dx_tf_side_case_min", data_structure.tfcoil_variables, 0.001, 1.0 ), - 173: IterationVariable("f_tritium", data_structure.physics_variables, 0.000, 1.000), + 173: IterationVariable( + "f_plasma_fuel_tritium", data_structure.physics_variables, 0.000, 1.000 + ), 174: IterationVariable("triang", data_structure.physics_variables, 0.00, 1.00), 175: IterationVariable("kappa", data_structure.physics_variables, 0.00, 10.00), } diff --git a/process/physics.py b/process/physics.py index 3aeabfc2c0..407a196901 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2207,7 +2207,7 @@ def physics(self): physics_variables.dlamie, current_drive_variables.e_beam_kev, physics_variables.f_plasma_fuel_deuterium, - physics_variables.f_tritium, + physics_variables.f_plasma_fuel_tritium, current_drive_variables.f_beam_tritium, physics_variables.sigmav_dt_average, physics_variables.temp_plasma_electron_density_weighted_kev, @@ -3298,7 +3298,10 @@ def plasma_composition() -> None: impurity_radiation.element2index("H_") ] = ( physics_variables.nd_protons - + (physics_variables.f_plasma_fuel_deuterium + physics_variables.f_tritium) + + ( + physics_variables.f_plasma_fuel_deuterium + + physics_variables.f_plasma_fuel_tritium + ) * physics_variables.nd_fuel_ions + physics_variables.nd_beam_ions ) / physics_variables.nd_plasma_electrons_vol_avg @@ -3402,7 +3405,7 @@ def plasma_composition() -> None: # Average atomic masses of injected fuel species physics_variables.m_fuel_amu = ( (constants.M_DEUTERON_AMU * physics_variables.f_plasma_fuel_deuterium) - + (constants.M_TRITON_AMU * physics_variables.f_tritium) + + (constants.M_TRITON_AMU * physics_variables.f_plasma_fuel_tritium) + (constants.M_HELION_AMU * physics_variables.f_helium3) ) @@ -3446,7 +3449,7 @@ def plasma_composition() -> None: / constants.M_DEUTERON_AMU ) + ( - physics_variables.f_tritium + physics_variables.f_plasma_fuel_tritium * physics_variables.nd_fuel_ions / constants.M_TRITON_AMU ) @@ -5066,8 +5069,8 @@ def outplas(self): po.ovarrf( self.outfile, "Tritium fuel fraction", - "(f_tritium)", - physics_variables.f_tritium, + "(f_plasma_fuel_tritium)", + physics_variables.f_plasma_fuel_tritium, ) po.ovarrf( self.outfile, diff --git a/process/stellarator.py b/process/stellarator.py index ceb28360dc..3778c24382 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4351,7 +4351,7 @@ def stphys(self, output): physics_variables.dlamie, current_drive_variables.e_beam_kev, physics_variables.f_plasma_fuel_deuterium, - physics_variables.f_tritium, + physics_variables.f_plasma_fuel_tritium, current_drive_variables.f_beam_tritium, physics_variables.sigmav_dt_average, physics_variables.temp_plasma_electron_density_weighted_kev, diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index b703270a8c..2322534bdf 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -626,7 +626,7 @@ boundu(28) = 1.0 * DESCRIPTION: Deuterium fuel fraction * JUSTIFICATION: Using default = 0.5 -*f_tritium = +*f_plasma_fuel_tritium = * DESCRIPTION: Tritium fuel fraction * JUSTIFICATION: Using default = 0.5 diff --git a/tests/unit/test_costs_1990.py b/tests/unit/test_costs_1990.py index 9c67edb40d..204f2e5d37 100644 --- a/tests/unit/test_costs_1990.py +++ b/tests/unit/test_costs_1990.py @@ -180,7 +180,7 @@ def acc2273_param(**kwargs): """ # Default parameters defaults = { - "f_tritium": 0.0001, + "f_plasma_fuel_tritium": 0.0001, "volrci": data_structure.buildings_variables.volrci, "wsvol": data_structure.buildings_variables.wsvol, "expected": approx(0.0, abs=0.00001), @@ -202,7 +202,7 @@ def acc2273_params(): return [ acc2273_param(), acc2273_param( - f_tritium=0.5, + f_plasma_fuel_tritium=0.5, volrci=1299783.4, wsvol=132304.1, expected=approx(74.12, abs=0.01), @@ -227,7 +227,9 @@ def acc2273_fix(request, monkeypatch, costs): # Some may be parameterised monkeypatch.setattr(data_structure.buildings_variables, "wsvol", param["wsvol"]) monkeypatch.setattr(data_structure.buildings_variables, "volrci", param["volrci"]) - monkeypatch.setattr(physics_variables, "f_tritium", param["f_tritium"]) + monkeypatch.setattr( + physics_variables, "f_plasma_fuel_tritium", param["f_plasma_fuel_tritium"] + ) # Mock result var as negative, as an expected result is 0 # Otherwise could get false positive result @@ -4480,7 +4482,7 @@ class Acc2273Param(NamedTuple): fkind: Any = None - f_tritium: Any = None + f_plasma_fuel_tritium: Any = None c227: Any = None @@ -4498,7 +4500,7 @@ class Acc2273Param(NamedTuple): wsvol=130018.25667917728, volrci=1205439.8543893537, fkind=1, - f_tritium=0.5, + f_plasma_fuel_tritium=0.5, c227=0, c2273=0, c22=0, @@ -4508,7 +4510,7 @@ class Acc2273Param(NamedTuple): wsvol=130255.93791329287, volrci=1206887.4047542624, fkind=1, - f_tritium=0.5, + f_plasma_fuel_tritium=0.5, c227=284.96904049038437, c2273=69.115208498727412, c22=3474.7391916096453, @@ -4535,7 +4537,9 @@ def test_acc2273_rut(acc2273param, monkeypatch, costs): monkeypatch.setattr(cost_variables, "fkind", acc2273param.fkind) - monkeypatch.setattr(physics_variables, "f_tritium", acc2273param.f_tritium) + monkeypatch.setattr( + physics_variables, "f_plasma_fuel_tritium", acc2273param.f_plasma_fuel_tritium + ) monkeypatch.setattr(cost_variables, "c227", acc2273param.c227) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index ecb0d451bb..bdadd8890b 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1360,7 +1360,7 @@ class PlasmaCompositionParam(NamedTuple): m_fuel_amu: Any = None - f_tritium: Any = None + f_plasma_fuel_tritium: Any = None nd_fuel_ions: Any = None @@ -1526,7 +1526,7 @@ class PlasmaCompositionParam(NamedTuple): i_plasma_ignited=0, f_alpha_electron=0, m_fuel_amu=0, - f_tritium=0.5, + f_plasma_fuel_tritium=0.5, nd_fuel_ions=0, m_ions_total_amu=0, nd_ions_total=0, @@ -1644,7 +1644,7 @@ class PlasmaCompositionParam(NamedTuple): i_plasma_ignited=0, f_alpha_electron=0.6845930883190634, m_fuel_amu=2.5, - f_tritium=0.5, + f_plasma_fuel_tritium=0.5, nd_fuel_ions=5.8589175702454272e19, m_ions_total_amu=2.7395439636787726, nd_ions_total=6.6125550702454276e19, @@ -1767,7 +1767,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "f_tritium", plasmacompositionparam.f_tritium + physics_variables, + "f_plasma_fuel_tritium", + plasmacompositionparam.f_plasma_fuel_tritium, ) monkeypatch.setattr( From 9e6a2f6de4b23030820d2d0209ef3fdfd98c7419 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 09:44:03 +0100 Subject: [PATCH 03/30] =?UTF-8?q?=F0=9F=94=84=20-=20Update=20variable=20na?= =?UTF-8?q?ming=20for=20helium-3=20fuel=20fraction=20to=20f=5Fplasma=5Ffue?= =?UTF-8?q?l=5Fhelium3=20for=20consistency=20across=20the=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fusion_reactions/plasma_reactions.md | 2 +- .../physics-models/plasma_composition.md | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/constraints.py | 6 +++--- process/costs.py | 2 +- process/data_structure/physics_variables.py | 6 +++--- process/fusion_reactions.py | 4 ++-- process/init.py | 4 ++-- process/input.py | 2 +- process/io/obsolete_vars.py | 4 ++-- process/io/plot_proc.py | 2 +- process/physics.py | 21 +++++++++++-------- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/test_costs_1990.py | 10 +++++---- tests/unit/test_physics.py | 18 +++++++++------- 16 files changed, 49 insertions(+), 40 deletions(-) diff --git a/documentation/physics-models/fusion_reactions/plasma_reactions.md b/documentation/physics-models/fusion_reactions/plasma_reactions.md index 64be033985..ca3b8922d4 100644 --- a/documentation/physics-models/fusion_reactions/plasma_reactions.md +++ b/documentation/physics-models/fusion_reactions/plasma_reactions.md @@ -55,7 +55,7 @@ profiles ## Setting of plasma fuel composition The fractional composition of the 'fuel' ions ($\text{D}$, $\text{T}$ and $^3\text{He}$) is -controlled using the three variables `f_plasma_fuel_deuterium`, `f_plasma_fuel_tritium` and `f_helium3`, respectively. +controlled using the three variables `f_plasma_fuel_deuterium`, `f_plasma_fuel_tritium` and `f_plasma_fuel_helium3`, respectively. More information about setting seeded impurities and simulating first wall sputtering can be found in the [composition and impurities section](../plasma_composition.md). It is also possible to optimise on the deuterium-tritium fuel mixture ratio. For this, `f_plasma_fuel_tritium` **must** be set as an iteration variable with `ixc = 173`. More info can be found [here](#fuel-ions-mixture-self-consistency). diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index f96e299d4e..e72859744d 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -36,7 +36,7 @@ using input array `f_nd_impurity_electrons(1,...,14)`. The available species alo As stated above, the number density fractions for hydrogen (all isotopes) and helium should not be set, as they are calculated by the code. This is to ensure plasma quasi-neutrality taking into account the fuel ratios -`f_plasma_fuel_deuterium`, `f_plasma_fuel_tritium` and `f_helium3`, and the alpha particle fraction `f_nd_alpha_electron` which may +`f_plasma_fuel_deuterium`, `f_plasma_fuel_tritium` and `f_plasma_fuel_helium3`, and the alpha particle fraction `f_nd_alpha_electron` which may be input by the user or selected as an iteration variable. !!! note "Location of impurities" diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 5d243cca60..7d8a85f99b 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -286,7 +286,7 @@ Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.20274886424344904e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 - 3-Helium_fuel_fraction___________________________________________________ (f_helium3)____________________ 0.00000000000000000e+00 + 3-Helium_fuel_fraction___________________________________________________ (f_plasma_fuel_helium3)____________________ 0.00000000000000000e+00 Total_fusion_power_(MW)__________________________________________________ (p_fusion_total_mw)_________________ 1.60956116199862254e+03 OP Fusion_rate_density:_total_(particles/m3/sec)____________________________ (fusden_total)____ 3.03874355943265088e+17 OP Fusion_rate_density:_plasma_(particles/m3/sec)___________________________ (fusden_plasma)___ 3.03874355943265088e+17 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index a2007e59cd..6aa4a2a904 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -359,7 +359,7 @@ Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*dnelimt)____________ 7.84515075612383478e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 - 3-Helium_fuel_fraction___________________________________________________ (f_helium3)____________________ 0.00000000000000000e+00 + 3-Helium_fuel_fraction___________________________________________________ (f_plasma_fuel_helium3)____________________ 0.00000000000000000e+00 Total_fusion_power_(MW)__________________________________________________ (p_fusion_total_mw)_________________ 1.74333215950657041e+03 OP Fusion_rate_density:_total_(particles/m3/sec)____________________________ (fusden_total)____ 3.29182443497713664e+17 OP Fusion_rate_density:_plasma_(particles/m3/sec)___________________________ (fusden_plasma)___ 3.29182443497713664e+17 OP diff --git a/process/constraints.py b/process/constraints.py index 6d8ee01e46..453094be8d 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -2373,16 +2373,16 @@ def constraint_equation_92(): f_plasma_fuel_deuterium: fraction of deuterium ions f_plasma_fuel_tritium: fraction of tritium ions - f_helium3: fraction of helium-3 ions + f_plasma_fuel_helium3: fraction of helium-3 ions """ f_plasma_fuel_deuterium = 1.0 - ( data_structure.physics_variables.f_plasma_fuel_tritium - + data_structure.physics_variables.f_helium3 + + data_structure.physics_variables.f_plasma_fuel_helium3 ) cc = 1.0 - ( f_plasma_fuel_deuterium + data_structure.physics_variables.f_plasma_fuel_tritium - + data_structure.physics_variables.f_helium3 + + data_structure.physics_variables.f_plasma_fuel_helium3 ) return ConstraintResult(cc, 1.0, cc) diff --git a/process/costs.py b/process/costs.py index 532482694f..e18b6cbe91 100644 --- a/process/costs.py +++ b/process/costs.py @@ -3073,7 +3073,7 @@ def coelc(self): * heat_transport_variables.p_plant_electric_net_mw / 1200.0e0 + 1.0e-6 - * physics_variables.f_helium3 + * physics_variables.f_plasma_fuel_helium3 * physics_variables.wtgpd * 1.0e-3 * cost_variables.uche3 diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 98cdd89398..0ba1b3fef2 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -478,7 +478,7 @@ """ -f_helium3: float = None +f_plasma_fuel_helium3: float = None """helium-3 fuel fraction""" @@ -1436,7 +1436,7 @@ def init_physics_variables(): global ffwal global f_nd_plasma_pedestal_greenwald global f_nd_plasma_separatrix_greenwald - global f_helium3 + global f_plasma_fuel_helium3 global figmer global fkzohm global fplhsep @@ -1689,7 +1689,7 @@ def init_physics_variables(): ffwal = 0.92 f_nd_plasma_pedestal_greenwald = 0.85 f_nd_plasma_separatrix_greenwald = 0.50 - f_helium3 = 0.0 + f_plasma_fuel_helium3 = 0.0 figmer = 0.0 fkzohm = 1.0 fplhsep = 1.0 diff --git a/process/fusion_reactions.py b/process/fusion_reactions.py index 8dbfa344ca..3527aad907 100644 --- a/process/fusion_reactions.py +++ b/process/fusion_reactions.py @@ -323,7 +323,7 @@ def dhe3_reaction(self) -> None: dhe3, ) * physics_variables.f_plasma_fuel_deuterium - * physics_variables.f_helium3 + * physics_variables.f_plasma_fuel_helium3 * ( self.plasma_profile.neprofile.profile_y * ( @@ -345,7 +345,7 @@ def dhe3_reaction(self) -> None: physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_fuel_ions ) - * (physics_variables.f_helium3 * physics_variables.nd_fuel_ions) + * (physics_variables.f_plasma_fuel_helium3 * physics_variables.nd_fuel_ions) ) # Power densities for different particles [MW/m^3] diff --git a/process/init.py b/process/init.py index 65dc6cf598..15b7598cc0 100644 --- a/process/init.py +++ b/process/init.py @@ -370,7 +370,7 @@ def check_process(inputs): # noqa: ARG001 1.0 - data_structure.physics_variables.f_plasma_fuel_deuterium - data_structure.physics_variables.f_plasma_fuel_tritium - - data_structure.physics_variables.f_helium3 + - data_structure.physics_variables.f_plasma_fuel_helium3 ) > 1e-6 ): @@ -378,7 +378,7 @@ def check_process(inputs): # noqa: ARG001 "Fuel ion fractions do not sum to 1.0", f_plasma_fuel_deuterium=data_structure.physics_variables.f_plasma_fuel_deuterium, f_plasma_fuel_tritium=data_structure.physics_variables.f_plasma_fuel_tritium, - f_helium3=data_structure.physics_variables.f_helium3, + f_plasma_fuel_helium3=data_structure.physics_variables.f_plasma_fuel_helium3, ) if ( diff --git a/process/input.py b/process/input.py index d7af843535..a9328923d3 100644 --- a/process/input.py +++ b/process/input.py @@ -169,7 +169,7 @@ def __post_init__(self): "f_nd_plasma_separatrix_greenwald": InputVariable( data_structure.physics_variables, float, range=(-1.0, 5.0) ), - "f_helium3": InputVariable( + "f_plasma_fuel_helium3": InputVariable( data_structure.physics_variables, float, range=(-1.0, 5.0) ), # TODO: does f_nd_impurity_electrons require an additional range? diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 27badf3118..6d6fa6d0e5 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -113,7 +113,7 @@ "fvolbi": "fhole", "fvolbo": "fhole", "fvolcry": None, - "idhe3": "f_helium3", + "idhe3": "f_plasma_fuel_helium3", "blnktth": None, "dz_blkt_upper": None, "theat": "t_fusion_ramp", @@ -131,7 +131,7 @@ "enbeam": "e_beam_kev", "fdeut": "f_plasma_fuel_deuterium", "ftrit": "f_plasma_fuel_tritium", - "fhe3": "f_helium3", + "fhe3": "f_plasma_fuel_helium3", "falpha": "f_p_alpha_plasma_deposited", "idensl": "i_density_limit", "ftburn": "ft_burn_min", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 58b1fe11d8..bb0d04b8ca 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2874,7 +2874,7 @@ def plot_main_plasma_information( textstr_reactions = ( f"$\\mathbf{{Fusion \\ Reactions:}}$\n \n" f"Fuel mixture: \n" - f"| D: {mfile_data.data['f_plasma_fuel_deuterium'].get_scan(scan):.2f} | T: {mfile_data.data['f_plasma_fuel_tritium'].get_scan(scan):.2f} | 3He: {mfile_data.data['f_helium3'].get_scan(scan):.2f} |\n\n" + f"| D: {mfile_data.data['f_plasma_fuel_deuterium'].get_scan(scan):.2f} | T: {mfile_data.data['f_plasma_fuel_tritium'].get_scan(scan):.2f} | 3He: {mfile_data.data['f_plasma_fuel_helium3'].get_scan(scan):.2f} |\n\n" f"Fusion Power, $P_{{\\text{{fus}}}}:$ {mfile_data.data['p_fusion_total_mw'].get_scan(scan):.2f} MW\n" f"D-T Power, $P_{{\\text{{fus,DT}}}}:$ {mfile_data.data['p_dt_total_mw'].get_scan(scan):.2f} MW\n" f"D-D Power, $P_{{\\text{{fus,DD}}}}:$ {mfile_data.data['p_dd_total_mw'].get_scan(scan):.2f} MW\n" diff --git a/process/physics.py b/process/physics.py index 407a196901..d5a6d7bd63 100644 --- a/process/physics.py +++ b/process/physics.py @@ -3235,7 +3235,8 @@ def plasma_composition() -> None: physics_variables.nd_protons = max( physics_variables.f_nd_protium_electrons * physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_alphas * (physics_variables.f_helium3 + 1.0e-3), + physics_variables.nd_alphas + * (physics_variables.f_plasma_fuel_helium3 + 1.0e-3), ) # rough estimate else: physics_variables.nd_protons = max( @@ -3287,8 +3288,10 @@ def plasma_composition() -> None: # Fuel ion density, nd_fuel_ions # For D-T-He3 mix, nd_fuel_ions = nD + nT + nHe3, while znfuel = nD + nT + 2*nHe3 - # So nd_fuel_ions = znfuel - nHe3 = znfuel - f_helium3*nd_fuel_ions - physics_variables.nd_fuel_ions = znfuel / (1.0 + physics_variables.f_helium3) + # So nd_fuel_ions = znfuel - nHe3 = znfuel - f_plasma_fuel_helium3*nd_fuel_ions + physics_variables.nd_fuel_ions = znfuel / ( + 1.0 + physics_variables.f_plasma_fuel_helium3 + ) # ====================================================================== @@ -3309,7 +3312,7 @@ def plasma_composition() -> None: impurity_radiation_module.f_nd_impurity_electron_array[ impurity_radiation.element2index("He") ] = ( - physics_variables.f_helium3 + physics_variables.f_plasma_fuel_helium3 * physics_variables.nd_fuel_ions / physics_variables.nd_plasma_electrons_vol_avg + physics_variables.f_nd_alpha_electron @@ -3406,7 +3409,7 @@ def plasma_composition() -> None: physics_variables.m_fuel_amu = ( (constants.M_DEUTERON_AMU * physics_variables.f_plasma_fuel_deuterium) + (constants.M_TRITON_AMU * physics_variables.f_plasma_fuel_tritium) - + (constants.M_HELION_AMU * physics_variables.f_helium3) + + (constants.M_HELION_AMU * physics_variables.f_plasma_fuel_helium3) ) # ====================================================================== @@ -3455,7 +3458,7 @@ def plasma_composition() -> None: ) + ( 4.0 - * physics_variables.f_helium3 + * physics_variables.f_plasma_fuel_helium3 * physics_variables.nd_fuel_ions / constants.M_HELION_AMU ) @@ -5075,8 +5078,8 @@ def outplas(self): po.ovarrf( self.outfile, "3-Helium fuel fraction", - "(f_helium3)", - physics_variables.f_helium3, + "(f_plasma_fuel_helium3)", + physics_variables.f_plasma_fuel_helium3, ) po.oblnkl(self.outfile) po.ocmmnt(self.outfile, "----------------------------") @@ -6961,7 +6964,7 @@ def bootstrap_fraction_sauter(plasma_profile: float) -> float: amain = np.full_like(inverse_q, physics_variables.m_fuel_amu) # Create new array of average main ion charge - zmain = np.full_like(inverse_q, 1.0 + physics_variables.f_helium3) + zmain = np.full_like(inverse_q, 1.0 + physics_variables.f_plasma_fuel_helium3) # Prevent division by zero if ne[nr - 1] == 0.0: diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index 2322534bdf..59f1a7070b 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -630,7 +630,7 @@ boundu(28) = 1.0 * DESCRIPTION: Tritium fuel fraction * JUSTIFICATION: Using default = 0.5 -*f_helium3 = +*f_plasma_fuel_helium3 = * DESCRIPTION: Helium-3 fuel fraction * JUSTIFICATION: Using default = 0.0 diff --git a/tests/unit/test_costs_1990.py b/tests/unit/test_costs_1990.py index 204f2e5d37..4d8a40b9dc 100644 --- a/tests/unit/test_costs_1990.py +++ b/tests/unit/test_costs_1990.py @@ -5613,7 +5613,7 @@ class CoelcParam(NamedTuple): wtgpd: Any = None - f_helium3: Any = None + f_plasma_fuel_helium3: Any = None t_cycle: Any = None @@ -5710,7 +5710,7 @@ class CoelcParam(NamedTuple): p_plant_electric_net_mw=493.01760776192009, itart=0, wtgpd=507.88376577416528, - f_helium3=0, + f_plasma_fuel_helium3=0, t_cycle=10864.426139387357, t_burn=0, outfile=11, @@ -5794,7 +5794,7 @@ class CoelcParam(NamedTuple): p_plant_electric_net_mw=422.4198205312706, itart=0, wtgpd=507.72524666099866, - f_helium3=0, + f_plasma_fuel_helium3=0, t_cycle=864.42613938735622, t_burn=10230.533336387549, outfile=11, @@ -5912,7 +5912,9 @@ def test_coelc(coelcparam, monkeypatch, costs): monkeypatch.setattr(physics_variables, "wtgpd", coelcparam.wtgpd) - monkeypatch.setattr(physics_variables, "f_helium3", coelcparam.f_helium3) + monkeypatch.setattr( + physics_variables, "f_plasma_fuel_helium3", coelcparam.f_plasma_fuel_helium3 + ) monkeypatch.setattr(times_variables, "t_cycle", coelcparam.t_cycle) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index bdadd8890b..e8567ebd6c 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -353,7 +353,7 @@ class BootstrapFractionSauterParam(NamedTuple): a_plasma_poloidal: Any = None - f_helium3: Any = None + f_plasma_fuel_helium3: Any = None temp_plasma_pedestal_kev: Any = None @@ -400,7 +400,7 @@ class BootstrapFractionSauterParam(NamedTuple): b_plasma_toroidal_on_axis=5.326133750416047, plasma_current=16528278.760008096, a_plasma_poloidal=38.39822223637151, - f_helium3=0, + f_plasma_fuel_helium3=0, temp_plasma_pedestal_kev=5.5, nd_plasma_electrons_vol_avg=8.016748468651018e19, te=12.570861186498382, @@ -486,7 +486,9 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph ) monkeypatch.setattr( - physics_variables, "f_helium3", bootstrapfractionsauterparam.f_helium3 + physics_variables, + "f_plasma_fuel_helium3", + bootstrapfractionsauterparam.f_plasma_fuel_helium3, ) monkeypatch.setattr( @@ -1406,7 +1408,7 @@ class PlasmaCompositionParam(NamedTuple): nd_beam_ions: Any = None - f_helium3: Any = None + f_plasma_fuel_helium3: Any = None nd_alphas: Any = None @@ -1549,7 +1551,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_deuterium=0.5, alphan=1, nd_beam_ions=0, - f_helium3=0, + f_plasma_fuel_helium3=0, nd_alphas=0, nd_plasma_electrons_vol_avg=7.5e19, nd_protons=0, @@ -1667,7 +1669,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_deuterium=0.5, alphan=1, nd_beam_ions=0, - f_helium3=0, + f_plasma_fuel_helium3=0, nd_alphas=7.5e18, nd_plasma_electrons_vol_avg=7.5e19, nd_protons=7500000000000000, @@ -1869,7 +1871,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "f_helium3", plasmacompositionparam.f_helium3 + physics_variables, + "f_plasma_fuel_helium3", + plasmacompositionparam.f_plasma_fuel_helium3, ) monkeypatch.setattr( From 626b2d589f8392516fa0c5875dcf8d72d8d00c31 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 10:07:51 +0100 Subject: [PATCH 04/30] =?UTF-8?q?=F0=9F=94=84=20-=20Rename=20total=20plasm?= =?UTF-8?q?a=20beta=20variable=20to=20beta=5Ftotal=5Fvol=5Favg=20for=20con?= =?UTF-8?q?sistency=20across=20the=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../physics-models/plasma_beta/plasma_beta.md | 2 +- .../data/csv_output_large_tokamak_MFILE.DAT | 6 ++-- examples/data/large_tokamak_1_MFILE.DAT | 6 ++-- examples/data/large_tokamak_2_MFILE.DAT | 6 ++-- examples/data/large_tokamak_3_MFILE.DAT | 6 ++-- examples/data/large_tokamak_4_MFILE.DAT | 6 ++-- examples/data/large_tokamak_IN.DAT | 2 +- examples/data/large_tokamak_eval_IN.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 6 ++-- examples/data/large_tokamak_nof_MFILE.DAT | 6 ++-- examples/data/scan_MFILE.DAT | 30 +++++++++---------- examples/data/scan_example_file_IN.DAT | 2 +- process/constraints.py | 28 +++++++++-------- process/data_structure/numerics.py | 2 +- process/data_structure/physics_variables.py | 8 ++--- process/input.py | 4 ++- process/io/mfile_comparison.py | 4 +-- process/io/plot_proc.py | 2 +- process/iteration_variables.py | 4 ++- process/physics.py | 27 ++++++++++------- process/stellarator.py | 4 +-- .../data/large_tokamak_1_MFILE.DAT | 2 +- .../data/large_tokamak_2_MFILE.DAT | 2 +- .../data/large_tokamak_3_MFILE.DAT | 2 +- .../data/large_tokamak_4_MFILE.DAT | 2 +- tests/integration/data/large_tokamak_IN.DAT | 2 +- .../integration/data/large_tokamak_MFILE.DAT | 2 +- .../data/large_tokamak_eval.IN.DAT | 2 +- tests/integration/data/scan_2D_MFILE.DAT | 2 +- tests/integration/test_main_int.py | 2 +- tests/integration/test_plot_scans.py | 2 +- .../input_files/large_tokamak.IN.DAT | 4 +-- .../input_files/large_tokamak_nof.IN.DAT | 4 +-- .../input_files/spherical_tokamak_eval.IN.DAT | 2 +- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/data/large_tokamak_IN.DAT | 2 +- tests/unit/data/large_tokamak_MFILE.DAT | 2 +- tests/unit/test_physics.py | 4 ++- tracking/tracking_data.py | 2 +- 39 files changed, 110 insertions(+), 95 deletions(-) diff --git a/documentation/physics-models/plasma_beta/plasma_beta.md b/documentation/physics-models/plasma_beta/plasma_beta.md index d49bff6c36..68b77146ac 100644 --- a/documentation/physics-models/plasma_beta/plasma_beta.md +++ b/documentation/physics-models/plasma_beta/plasma_beta.md @@ -350,7 +350,7 @@ This constraint can be activated by stating `icc = 1` in the input file. Ensures the relationship between $\beta$, density, temperature and total magnetic field is withheld by checking the fixed input or iteration variable $\mathtt{beta}$ is consistent in value with the rest of the physics parameters $$ -\mathtt{beta} \equiv \frac{2\mu_0 \langle n_{\text{e}}T_{\text{e}}+n_{\text{i}}T_{\text{i}}\rangle}{B^2} + \beta_{\alpha} + \beta_{\text{beam}} +\mathtt{beta_total_vol_avg} \equiv \frac{2\mu_0 \langle n_{\text{e}}T_{\text{e}}+n_{\text{i}}T_{\text{i}}\rangle}{B^2} + \beta_{\alpha} + \beta_{\text{beam}} $$ **It is highly recommended to always have this constraint on as it is a global consistency checker** diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index 5007d37210..83f3dbe9a2 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -342,7 +342,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4251E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8387E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.6055E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.6055E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2531E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.7123E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.4814E-03 OP @@ -1216,8 +1216,8 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index b93816bdb0..f726007bd8 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP @@ -1211,8 +1211,8 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index 4c2cf34cd6..4b20967a38 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP @@ -1211,8 +1211,8 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 138d7f813d..19ce55885e 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP @@ -1211,8 +1211,8 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index bf82e9863e..ab66ff6d6c 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP @@ -1211,8 +1211,8 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/examples/data/large_tokamak_IN.DAT b/examples/data/large_tokamak_IN.DAT index 7eec25f7ed..47b92da4e4 100644 --- a/examples/data/large_tokamak_IN.DAT +++ b/examples/data/large_tokamak_IN.DAT @@ -24,7 +24,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/examples/data/large_tokamak_eval_IN.DAT b/examples/data/large_tokamak_eval_IN.DAT index ed0111f838..710bf55d8c 100644 --- a/examples/data/large_tokamak_eval_IN.DAT +++ b/examples/data/large_tokamak_eval_IN.DAT @@ -279,7 +279,7 @@ zref(10) = 1.0 alphan = 1.00 * density profile index alphat = 1.45 * temperature profile index aspect = 3.0 * aspect ratio (`iteration variable 1`) -beta = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) +beta_total_vol_avg = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) b_plasma_toroidal_on_axis = 5.318322174644904 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 7.796223900029837e+19 * electron density (/m3) (`iteration variable 6`) beta_norm_max = 3.0 * Troyon-like coefficient for beta scaling calculated diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 7d8a85f99b..193635077f 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -202,7 +202,7 @@ Safety_factor_at_95%_flux_surface________________________________________ (q95)__________________________ 3.73390781931285565e+00 Cylindrical_safety_factor_(qcyl)_________________________________________ (qstar)________________________ 4.12802018540024562e+00 OP Upper_limit_on_thermal_beta______________________________________________ (beta_max)_____________________ 6.75897673577628422e-02 OP - Total_plasma_beta________________________________________________________ (beta)_________________________ 3.23040881535548857e-02 + Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 3.23040881535548857e-02 Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.32822381700080405e+00 OP @@ -1188,7 +1188,7 @@ boundl(3) = 8.0 boundu(3) = 9.0 ixc = 4 * temp_plasma_electron_vol_avg_kev boundu(4) = 100.0 -ixc = 5 * beta +ixc = 5 * beta_total_vol_avg ixc = 6 * nd_plasma_electrons_vol_avg ixc = 10 * hfact boundu(10) = 1.2 @@ -1459,7 +1459,7 @@ zref(10) = 1.0 alphan = 1.00 * density profile index alphat = 1.45 * temperature profile index aspect = 3.0 * aspect ratio (`iteration variable 1`) -beta = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) +beta_total_vol_avg = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) b_plasma_toroidal_on_axis = 5.318322174644904 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 7.796223900029837e+19 * electron density (/m3) (`iteration variable 6`) beta_norm_max = 3.0 * Troyon-like coefficient for beta scaling calculated diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 6aa4a2a904..6060c96f11 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -274,7 +274,7 @@ Safety_factor_at_95%_flux_surface________________________________________ (q95)__________________________ 3.05729664268825285e+00 Cylindrical_safety_factor_(qcyl)_________________________________________ (qstar)________________________ 3.37999298978303386e+00 OP Upper_limit_on_thermal_beta______________________________________________ (beta_max)_____________________ 7.35303866910386600e-02 OP - Total_plasma_beta________________________________________________________ (beta)_________________________ 4.48303922556954615e-02 + Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 4.48303922556954615e-02 Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.25053557633615986e+00 OP @@ -1243,8 +1243,8 @@ neqns = 3 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/examples/data/scan_MFILE.DAT b/examples/data/scan_MFILE.DAT index 915ae526de..4992961212 100644 --- a/examples/data/scan_MFILE.DAT +++ b/examples/data/scan_MFILE.DAT @@ -198,7 +198,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -1193,7 +1193,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -2188,7 +2188,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -3183,7 +3183,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -4178,7 +4178,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -5173,7 +5173,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -6168,7 +6168,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -7163,7 +7163,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -8158,7 +8158,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -9010,7 +9010,7 @@ ixc = 3 * rmajor boundu(3) = 13 ixc = 4 * temp_plasma_electron_vol_avg_keV boundu(4) = 150.0 -ixc = 5 * beta +ixc = 5 * beta_total_vol_avg ixc = 6 * nd_plasma_electrons_vol_avg ixc = 9 * fdene boundu(9) = 1.2 @@ -9103,7 +9103,7 @@ dr_shld_blkt_gap = 0.02 * gap between vacuum vessel and blanket (m) *---------------Constraint Variables---------------* -fbeta_max = 0.4815 * F-value for beta limit +fbeta_max = 0.4815 * F-value for beta_total_vol_avg limit fdene = 1.2 * F-value for density limit fp_fusion_total_max_mw = 1 * F-value for maximum fusion power fjohc = 0.25 * F-value for central solenoid current at end-of-flattop @@ -9233,13 +9233,13 @@ alphan = 1.00 * Density profile index alphat = 1.45 * Temperature profile index aspect = 3.1 * Aspect ratio (iteration variable 1) nd_plasma_electrons_vol_avg = 7.983e+19 * Electron density (/m3) (iteration variable 6) -beta_norm_max = 3.0 * (troyon-like) coefficient for beta scaling; +beta_norm_max = 3.0 * (troyon-like) coefficient for beta_total_vol_avg scaling; fkzohm = 1.0245 * Zohm elongation scaling adjustment factor (i_plasma_geometry=2; 3) f_c_plasma_non_inductive = 0.4434 * Fraction of the plasma current produced by ejima_coeff = 0.3 * Ejima coefficient for resistive startup v-s formula hfact = 1.1 * H factor on energy confinement times (iteration variable 10) i_bootstrap_current = 4 * Switch for bootstrap current scaling; -i_beta_component = 1 * Switch for beta limit scaling (constraint equation 24); +i_beta_component = 1 * Switch for beta_total_vol_avg limit scaling (constraint equation 24); i_plasma_current = 4 * Switch for plasma current scaling to use; i_density_limit = 7 * Switch for density limit to enforce (constraint equation 5); i_beta_fast_alpha = 1 * Switch for fast alpha pressure calculation; @@ -9250,7 +9250,7 @@ nd_plasma_pedestal_electron = 0.678e20 * Electron density of pedestal (/m3) ( nd_plasma_separatrix_electron = 0.2e20 * Electron density at separatrix (/m3) (i_plasma_pedestal=1) radius_plasma_pedestal_density_norm = 0.94 * R/a of density pedestal (i_plasma_pedestal=1) radius_plasma_pedestal_temp_norm = 0.94 * R/a of temperature pedestal (i_plasma_pedestal=1) -tbeta = 2.0 * Temperature profile index beta (i_plasma_pedestal=1) +tbeta = 2.0 * Temperature profile index beta_total_vol_avg (i_plasma_pedestal=1) temp_plasma_pedestal_kev = 5.5 * Electron temperature of pedestal (kev) (i_plasma_pedestal=1) temp_plasma_separatrix_kev = 0.1 * Electron temperature at separatrix (kev) (i_plasma_pedestal=1) i_confinement_time = 34 * Switch for energy confinement time scaling law @@ -9315,7 +9315,7 @@ t_burn = 1.0d4 * Burn time (s) (calculated if i_pulsed_plant=1) b_plasma_toroidal_on_axis = 5.3292E+00 rmajor = 8.8901E+00 temp_plasma_electron_vol_avg_keV = 1.2330E+01 - beta = 3.1421E-02 + beta_total_vol_avg = 3.1421E-02 nd_plasma_electrons_vol_avg = 7.4321E+19 fdene = 1.2000E+00 oacdcp = 8.6739E+06 diff --git a/examples/data/scan_example_file_IN.DAT b/examples/data/scan_example_file_IN.DAT index 6da89b8315..210cf3e88a 100644 --- a/examples/data/scan_example_file_IN.DAT +++ b/examples/data/scan_example_file_IN.DAT @@ -24,7 +24,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/process/constraints.py b/process/constraints.py index 453094be8d..b34073c4d7 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -127,7 +127,7 @@ def constraint_equation_1(): author: J Morris - beta: total plasma beta + beta_total_vol_avg: total plasma beta beta_{ft}: fast alpha beta component beta_{NBI}: neutral beam beta component n_e: electron density [/m3] @@ -152,12 +152,14 @@ def constraint_equation_1(): ) / data_structure.physics_variables.b_plasma_total**2 ) - / data_structure.physics_variables.beta + / data_structure.physics_variables.beta_total_vol_avg ) return ConstraintResult( normalised_residual=cc, - constraint_value=(data_structure.physics_variables.beta * (1.0 - cc)), - constraint_error=(data_structure.physics_variables.beta * cc), + constraint_value=( + data_structure.physics_variables.beta_total_vol_avg * (1.0 - cc) + ), + constraint_error=(data_structure.physics_variables.beta_total_vol_avg * cc), ) @@ -798,7 +800,7 @@ def constraint_equation_24(): - 1 use stellarator model fbeta_max: f-value for beta limit beta_max: allowable beta - beta: total plasma beta (calculated if i_plasma_pedestal =3) + beta_total_vol_avg: total plasma beta (calculated if i_plasma_pedestal =3) beta_fast_alpha: fast alpha beta component beta_beam: neutral beam beta component b_plasma_toroidal_on_axis: toroidal field @@ -810,21 +812,21 @@ def constraint_equation_24(): or data_structure.stellarator_variables.istell != 0 ): cc = ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg / data_structure.physics_variables.beta_max - 1.0 * data_structure.constraint_variables.fbeta_max ) con = data_structure.physics_variables.beta_max err = ( data_structure.physics_variables.beta_max - - data_structure.physics_variables.beta + - data_structure.physics_variables.beta_total_vol_avg / data_structure.constraint_variables.fbeta_max ) # Here, the beta limit applies to only the thermal component, not the fast alpha or neutral beam parts elif data_structure.physics_variables.i_beta_component == 1: cc = ( ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha - data_structure.physics_variables.beta_beam ) @@ -835,7 +837,7 @@ def constraint_equation_24(): err = ( data_structure.physics_variables.beta_max - ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha - data_structure.physics_variables.beta_beam ) @@ -845,7 +847,7 @@ def constraint_equation_24(): elif data_structure.physics_variables.i_beta_component == 2: cc = ( ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha ) / data_structure.physics_variables.beta_max @@ -853,14 +855,14 @@ def constraint_equation_24(): ) con = data_structure.physics_variables.beta_max * (1.0 - cc) err = ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha ) * cc # Beta limit applies to toroidal beta elif data_structure.physics_variables.i_beta_component == 3: cc = ( ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg * ( data_structure.physics_variables.b_plasma_total / data_structure.physics_variables.b_plasma_toroidal_on_axis @@ -874,7 +876,7 @@ def constraint_equation_24(): err = ( data_structure.physics_variables.beta_max - ( - data_structure.physics_variables.beta + data_structure.physics_variables.beta_total_vol_avg * ( data_structure.physics_variables.b_plasma_total / data_structure.physics_variables.b_plasma_toroidal_on_axis diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index a5cfa4ec98..b948f77e1a 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -201,7 +201,7 @@ * ( 2) b_plasma_toroidal_on_axis * ( 3) rmajor * ( 4) temp_plasma_electron_vol_avg_kev -* ( 5) beta +* ( 5) beta_total_vol_avg * ( 6) nd_plasma_electrons_vol_avg * ( 7) f_nd_beam_electron * ( 8) fbeta_poloidal_eps (f-value for equation 6) diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 0ba1b3fef2..8619157fce 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -213,8 +213,8 @@ """multiplier for beam-background fusion calculation""" -beta: float = None -"""total plasma beta (`iteration variable 5`) (calculated if stellarator)""" +beta_total_vol_avg: float = None +"""Volume averaged total plasma beta (`iteration variable 5`) (calculated if stellarator)""" beta_fast_alpha: float = None @@ -1375,7 +1375,7 @@ def init_physics_variables(): global alphat global aspect global beamfus0 - global beta + global beta_total_vol_avg global beta_fast_alpha global beta_max global beta_min @@ -1628,7 +1628,7 @@ def init_physics_variables(): alphat = 0.5 aspect = 2.907 beamfus0 = 1.0 - beta = 0.042 + beta_total_vol_avg = 0.042 beta_fast_alpha = 0.0 beta_max = 0.0 beta_min = 0.0 diff --git a/process/input.py b/process/input.py index a9328923d3..9a040afc5d 100644 --- a/process/input.py +++ b/process/input.py @@ -116,7 +116,9 @@ def __post_init__(self): "beamfus0": InputVariable( data_structure.physics_variables, float, range=(0.01, 10.0) ), - "beta": InputVariable(data_structure.physics_variables, float, range=(0.0, 1.0)), + "beta_total_vol_avg": InputVariable( + data_structure.physics_variables, float, range=(0.0, 1.0) + ), "beta_max": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), diff --git a/process/io/mfile_comparison.py b/process/io/mfile_comparison.py index 59b7b1efe8..8f0fda2022 100644 --- a/process/io/mfile_comparison.py +++ b/process/io/mfile_comparison.py @@ -114,7 +114,7 @@ "plasma_current_MA", "b_plasma_toroidal_on_axis", "q95", - "beta", + "beta_total_vol_avg", "normalised_thermal_beta", "beta_norm_total", "thermal_beta", @@ -220,7 +220,7 @@ "plasma_current_MA", "b_plasma_toroidal_on_axis", "q95", - "beta", + "beta_total_vol_avg", "temp_plasma_electron_vol_avg_kev", "nd_plasma_electrons_vol_avg", "p_hcd_injected_total_mw", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index bb0d04b8ca..a6d8f57c0c 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2635,7 +2635,7 @@ def plot_main_plasma_information( # Add beta information textstr_beta = ( f"$\\mathbf{{Beta \\ Information:}}$\n \n" - f"Total beta,$ \\ \\beta$: {mfile_data.data['beta'].get_scan(scan):.4f}\n" + f"Total beta,$ \\ \\beta$: {mfile_data.data['beta_total_vol_avg'].get_scan(scan):.4f}\n" f"Thermal beta,$ \\ \\beta_{{\\text{{thermal}}}}$: {mfile_data.data['beta_thermal'].get_scan(scan):.4f}\n" f"Toroidal beta,$ \\ \\beta_{{\\text{{t}}}}$: {mfile_data.data['beta_toroidal'].get_scan(scan):.4f}\n" f"Poloidal beta,$ \\ \\beta_{{\\text{{p}}}}$: {mfile_data.data['beta_poloidal'].get_scan(scan):.4f}\n" diff --git a/process/iteration_variables.py b/process/iteration_variables.py index e4a6bc7cfd..5778199737 100644 --- a/process/iteration_variables.py +++ b/process/iteration_variables.py @@ -40,7 +40,9 @@ class IterationVariable: 4: IterationVariable( "temp_plasma_electron_vol_avg_kev", data_structure.physics_variables, 5.0, 150.0 ), - 5: IterationVariable("beta", data_structure.physics_variables, 0.001, 1.0), + 5: IterationVariable( + "beta_total_vol_avg", data_structure.physics_variables, 0.001, 1.0 + ), 6: IterationVariable( "nd_plasma_electrons_vol_avg", data_structure.physics_variables, 2.0e19, 1.0e21 ), diff --git a/process/physics.py b/process/physics.py index d5a6d7bd63..fd44dfb80b 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1742,7 +1742,7 @@ def physics(self): # ----------------------------------------------------- physics_variables.beta_toroidal = ( - physics_variables.beta + physics_variables.beta_total_vol_avg * physics_variables.b_plasma_total**2 / physics_variables.b_plasma_toroidal_on_axis**2 ) @@ -1751,11 +1751,11 @@ def physics(self): physics_variables.beta_poloidal = calculate_poloidal_beta( physics_variables.b_plasma_total, physics_variables.b_plasma_poloidal_average, - physics_variables.beta, + physics_variables.beta_total_vol_avg, ) physics_variables.beta_thermal = ( - physics_variables.beta + physics_variables.beta_total_vol_avg - physics_variables.beta_fast_alpha - physics_variables.beta_beam ) @@ -1821,7 +1821,7 @@ def physics(self): # Plasma thermal energy derived from the total beta physics_variables.e_plasma_beta = ( 1.5e0 - * physics_variables.beta + * physics_variables.beta_total_vol_avg * physics_variables.b_plasma_total * physics_variables.b_plasma_total / (2.0e0 * constants.RMU0) @@ -1893,13 +1893,15 @@ def physics(self): # Hender scaling for diamagnetic current at tight physics_variables.aspect ratio current_drive_variables.f_c_plasma_diamagnetic_hender = ( - diamagnetic_fraction_hender(physics_variables.beta) + diamagnetic_fraction_hender(physics_variables.beta_total_vol_avg) ) # SCENE scaling for diamagnetic current current_drive_variables.f_c_plasma_diamagnetic_scene = ( diamagnetic_fraction_scene( - physics_variables.beta, physics_variables.q95, physics_variables.q0 + physics_variables.beta_total_vol_avg, + physics_variables.q95, + physics_variables.q0, ) ) @@ -1918,7 +1920,7 @@ def physics(self): # Pfirsch-Schlüter scaling for diamagnetic current current_drive_variables.f_c_plasma_pfirsch_schluter_scene = ps_fraction_scene( - physics_variables.beta + physics_variables.beta_total_vol_avg ) if physics_variables.i_pfirsch_schluter_current == 1: @@ -1935,7 +1937,7 @@ def physics(self): current_drive_variables.cboot * self.bootstrap_fraction_iter89( physics_variables.aspect, - physics_variables.beta, + physics_variables.beta_total_vol_avg, physics_variables.b_plasma_total, physics_variables.plasma_current, physics_variables.q95, @@ -3817,7 +3819,7 @@ def calculate_plasma_current( # Normalised beta from Troyon beta limit physics_variables.beta_norm_total = ( 1.0e8 - * physics_variables.beta + * physics_variables.beta_total_vol_avg * rminor * b_plasma_toroidal_on_axis / plasma_current @@ -4336,7 +4338,12 @@ def outplas(self): "OP ", ) - po.ovarre(self.outfile, "Total plasma beta", "(beta)", physics_variables.beta) + po.ovarre( + self.outfile, + "Total plasma beta", + "(beta)", + physics_variables.beta_total_vol_avg, + ) if physics_variables.i_beta_component == 0: po.ovarrf( self.outfile, diff --git a/process/stellarator.py b/process/stellarator.py index 3778c24382..4d16b0f6b9 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4256,7 +4256,7 @@ def stphys(self, output): # Set physics_variables.beta as a consequence: # This replaces constraint equation 1 as it is just an equality. - physics_variables.beta = ( + physics_variables.beta_total_vol_avg = ( physics_variables.beta_fast_alpha + physics_variables.beta_beam + 2.0e3 @@ -4272,7 +4272,7 @@ def stphys(self, output): ) physics_variables.e_plasma_beta = ( 1.5e0 - * physics_variables.beta + * physics_variables.beta_total_vol_avg * physics_variables.b_plasma_total * physics_variables.b_plasma_total / (2.0e0 * constants.RMU0) diff --git a/tests/integration/data/large_tokamak_1_MFILE.DAT b/tests/integration/data/large_tokamak_1_MFILE.DAT index c76aa34f0a..83c9261fca 100644 --- a/tests/integration/data/large_tokamak_1_MFILE.DAT +++ b/tests/integration/data/large_tokamak_1_MFILE.DAT @@ -1211,7 +1211,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/data/large_tokamak_2_MFILE.DAT b/tests/integration/data/large_tokamak_2_MFILE.DAT index 334bba70ac..00d614f1f6 100644 --- a/tests/integration/data/large_tokamak_2_MFILE.DAT +++ b/tests/integration/data/large_tokamak_2_MFILE.DAT @@ -1212,7 +1212,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/data/large_tokamak_3_MFILE.DAT b/tests/integration/data/large_tokamak_3_MFILE.DAT index a5474c4985..fc2aa068b6 100644 --- a/tests/integration/data/large_tokamak_3_MFILE.DAT +++ b/tests/integration/data/large_tokamak_3_MFILE.DAT @@ -1212,7 +1212,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/data/large_tokamak_4_MFILE.DAT b/tests/integration/data/large_tokamak_4_MFILE.DAT index 024e6f94e1..7a27be30c2 100644 --- a/tests/integration/data/large_tokamak_4_MFILE.DAT +++ b/tests/integration/data/large_tokamak_4_MFILE.DAT @@ -1212,7 +1212,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/data/large_tokamak_IN.DAT b/tests/integration/data/large_tokamak_IN.DAT index b0e748006c..809c7f7a32 100644 --- a/tests/integration/data/large_tokamak_IN.DAT +++ b/tests/integration/data/large_tokamak_IN.DAT @@ -24,7 +24,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/data/large_tokamak_MFILE.DAT b/tests/integration/data/large_tokamak_MFILE.DAT index 66e8a75b85..9167a5e0b5 100644 --- a/tests/integration/data/large_tokamak_MFILE.DAT +++ b/tests/integration/data/large_tokamak_MFILE.DAT @@ -1448,7 +1448,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/data/large_tokamak_eval.IN.DAT b/tests/integration/data/large_tokamak_eval.IN.DAT index 4c3d79d999..1195723a66 100644 --- a/tests/integration/data/large_tokamak_eval.IN.DAT +++ b/tests/integration/data/large_tokamak_eval.IN.DAT @@ -279,7 +279,7 @@ zref(10) = 1.0 alphan = 1.00 * density profile index alphat = 1.45 * temperature profile index aspect = 3.0 * aspect ratio (`iteration variable 1`) -beta = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) +beta_total_vol_avg = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) b_plasma_toroidal_on_axis = 5.318322174644904 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 7.796223900029837e+19 * electron density (/m3) (`iteration variable 6`) beta_norm_max = 3.0 * Troyon-like coefficient for beta scaling calculated diff --git a/tests/integration/data/scan_2D_MFILE.DAT b/tests/integration/data/scan_2D_MFILE.DAT index 88a97816b6..013217e935 100644 --- a/tests/integration/data/scan_2D_MFILE.DAT +++ b/tests/integration/data/scan_2D_MFILE.DAT @@ -17505,7 +17505,7 @@ sweep_2 = 5.2,5.1,5.0 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/integration/test_main_int.py b/tests/integration/test_main_int.py index 6c2969416b..1914135300 100644 --- a/tests/integration/test_main_int.py +++ b/tests/integration/test_main_int.py @@ -112,6 +112,6 @@ def test_single_run_with_mfilejson(temp_data): raise AssertionError("The JSON file is not valid JSON") from err # Check if the JSON contains expected outputs. - expected_keys = ["rmajor", "b_plasma_toroidal_on_axis", "beta"] + expected_keys = ["rmajor", "b_plasma_toroidal_on_axis", "beta_total_vol_avg"] for key in expected_keys: assert key in json_data, f"Expected key '{key}' not found in the JSON file" diff --git a/tests/integration/test_plot_scans.py b/tests/integration/test_plot_scans.py index 1834164084..dcf78493b2 100644 --- a/tests/integration/test_plot_scans.py +++ b/tests/integration/test_plot_scans.py @@ -67,7 +67,7 @@ def test_plot_scans_2d_contour(temp_data, scan_2d_mfile_name): "-f", str(mfile), "-yv", - "beta", + "beta_total_vol_avg", "-2DC", "--outputdir", str(temp_data), diff --git a/tests/regression/input_files/large_tokamak.IN.DAT b/tests/regression/input_files/large_tokamak.IN.DAT index 44e4d84bdc..880ae49bd5 100644 --- a/tests/regression/input_files/large_tokamak.IN.DAT +++ b/tests/regression/input_files/large_tokamak.IN.DAT @@ -23,8 +23,8 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/tests/regression/input_files/large_tokamak_nof.IN.DAT b/tests/regression/input_files/large_tokamak_nof.IN.DAT index 845fcc5e24..963b05f029 100644 --- a/tests/regression/input_files/large_tokamak_nof.IN.DAT +++ b/tests/regression/input_files/large_tokamak_nof.IN.DAT @@ -25,8 +25,8 @@ neqns = 3 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta -beta = 0.03 +ixc = 5 * beta_total_vol_avg +beta_total_vol_avg = 0.03 * Global power balance * *----------------------* diff --git a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT index 3888324ac6..3f17f8cdf9 100644 --- a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT @@ -267,7 +267,7 @@ i_alphaj = 0 * Current profile index selection (0 = user input) alphan = 0.9 * density profile index alphat = 1.4 * temperature profile index aspect = 1.8 * aspect ratio (`iteration variable 1`) -beta = 0.13134204235647895 * total plasma beta (`iteration variable 5`) (calculated if stellarator) +beta_total_vol_avg = 0.13134204235647895 * total plasma beta (`iteration variable 5`) (calculated if stellarator) b_plasma_toroidal_on_axis = 3.0 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 9.69888313737236e+19 * electron density (/m3) (`iteration variable 6`) beta_norm_max = 5.0 * Troyon-like coefficient for beta scaling diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index 59f1a7070b..d176c076fb 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -310,7 +310,7 @@ icc = 24 * JUSTIFICATION: Turned off, not in use. icc=24. Allow to be calculated in-situ ixc = 5 -beta = 0.2 +beta_total_vol_avg = 0.2 boundl(5) = 0.01 boundu(5) = 1.0 * DESCRIPTION: Total Plasma Beta, diff --git a/tests/unit/data/large_tokamak_IN.DAT b/tests/unit/data/large_tokamak_IN.DAT index 276a0e138f..a706920fb2 100644 --- a/tests/unit/data/large_tokamak_IN.DAT +++ b/tests/unit/data/large_tokamak_IN.DAT @@ -24,7 +24,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/unit/data/large_tokamak_MFILE.DAT b/tests/unit/data/large_tokamak_MFILE.DAT index e01ddf22be..9dc2177a40 100644 --- a/tests/unit/data/large_tokamak_MFILE.DAT +++ b/tests/unit/data/large_tokamak_MFILE.DAT @@ -1215,7 +1215,7 @@ epsvmc = 1e-7 *------------------* icc = 1 ixc = 5 * beta -beta = 0.03 +beta_total_vol_avg =0.03 * Global power balance * *----------------------* diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index e8567ebd6c..ef7434ce8a 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1218,7 +1218,9 @@ def test_calculate_plasma_current(plasmacurrentparam, monkeypatch, physics): plasmacurrentparam.beta_norm_total, ) - monkeypatch.setattr(physics_variables, "beta", plasmacurrentparam.beta) + monkeypatch.setattr( + physics_variables, "beta_total_vol_avg", plasmacurrentparam.beta + ) b_plasma_poloidal_average, qstar, plasma_current = physics.calculate_plasma_current( i_plasma_current=plasmacurrentparam.i_plasma_current, diff --git a/tracking/tracking_data.py b/tracking/tracking_data.py index 3ddcdeb3ce..aeac14ced2 100644 --- a/tracking/tracking_data.py +++ b/tracking/tracking_data.py @@ -122,7 +122,7 @@ class ProcessTracker: "Physics.rmajor", "Physics.q95", "Physics.temp_plasma_electron_vol_avg_kev", - "Physics.beta", + "Physics.beta_total_vol_avg", "Physics.f_c_plasma_inductive", "Physics.zeff", "Physics.b_plasma_toroidal_on_axis", From 5bf2a346333b0ef6e95e759174dd1e9e94f63b48 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 11:03:43 +0100 Subject: [PATCH 05/30] =?UTF-8?q?=F0=9F=94=84=20-=20Rename=20toroidal=20be?= =?UTF-8?q?ta=20variable=20to=20beta=5Ftoroidal=5Fvol=5Favg=20for=20consis?= =?UTF-8?q?tency=20across=20the=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 8 ++++---- process/io/plot_proc.py | 2 +- process/physics.py | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 193635077f..3f6b81f70b 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -206,7 +206,7 @@ Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.32822381700080405e+00 OP - Total_toroidal_beta______________________________________________________ (beta_toroidal)________________ 3.31093495352616854e-02 OP + Total_toroidal_beta______________________________________________________ (beta_toroidal_vol_avg)________________ 3.31093495352616854e-02 OP Fast_alpha_beta__________________________________________________________ (beta_fast_alpha)______________ 4.31753385900027382e-03 OP Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.54271719682202629e-01 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 6060c96f11..dae904a56e 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -278,7 +278,7 @@ Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.25053557633615986e+00 OP - Total_toroidal_beta______________________________________________________ (beta_toroidal)________________ 4.64972707732098992e-02 OP + Total_toroidal_beta______________________________________________________ (beta_toroidal_vol_avg)________________ 4.64972707732098992e-02 OP Fast_alpha_beta__________________________________________________________ (beta_fast_alpha)______________ 5.34272993662247321e-03 OP Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.35301246588149487e-01 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 8619157fce..7d76a7be83 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -241,8 +241,8 @@ """Poloidal beta and inverse aspcet ratio product""" -beta_toroidal: float = None -"""toroidal beta""" +beta_toroidal_vol_avg: float = None +"""Volume averaged toroidal beta""" beta_thermal: float = None @@ -1382,7 +1382,7 @@ def init_physics_variables(): global beta_beam global beta_poloidal global beta_poloidal_eps - global beta_toroidal + global beta_toroidal_vol_avg global beta_thermal global beta_thermal_poloidal global beta_thermal_toroidal @@ -1635,7 +1635,7 @@ def init_physics_variables(): beta_beam = 0.0 beta_poloidal = 0.0 beta_poloidal_eps = 0.0 - beta_toroidal = 0.0 + beta_toroidal_vol_avg = 0.0 beta_thermal = 0.0 beta_thermal_poloidal = 0.0 beta_thermal_toroidal = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index a6d8f57c0c..83fa0141b8 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2637,7 +2637,7 @@ def plot_main_plasma_information( f"$\\mathbf{{Beta \\ Information:}}$\n \n" f"Total beta,$ \\ \\beta$: {mfile_data.data['beta_total_vol_avg'].get_scan(scan):.4f}\n" f"Thermal beta,$ \\ \\beta_{{\\text{{thermal}}}}$: {mfile_data.data['beta_thermal'].get_scan(scan):.4f}\n" - f"Toroidal beta,$ \\ \\beta_{{\\text{{t}}}}$: {mfile_data.data['beta_toroidal'].get_scan(scan):.4f}\n" + f"Toroidal beta,$ \\ \\beta_{{\\text{{t}}}}$: {mfile_data.data['beta_toroidal_vol_avg'].get_scan(scan):.4f}\n" f"Poloidal beta,$ \\ \\beta_{{\\text{{p}}}}$: {mfile_data.data['beta_poloidal'].get_scan(scan):.4f}\n" f"Fast-alpha beta,$ \\ \\beta_{{\\alpha}}$: {mfile_data.data['beta_fast_alpha'].get_scan(scan):.4f}\n" f"Normalised total beta,$ \\ \\beta_{{\\text{{N}}}}$: {mfile_data.data['beta_norm_total'].get_scan(scan):.4f}\n" diff --git a/process/physics.py b/process/physics.py index fd44dfb80b..c7833b924d 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1741,7 +1741,7 @@ def physics(self): # Beta Components # ----------------------------------------------------- - physics_variables.beta_toroidal = ( + physics_variables.beta_toroidal_vol_avg = ( physics_variables.beta_total_vol_avg * physics_variables.b_plasma_total**2 / physics_variables.b_plasma_toroidal_on_axis**2 @@ -1952,7 +1952,7 @@ def physics(self): * self.bootstrap_fraction_nevins( physics_variables.alphan, physics_variables.alphat, - physics_variables.beta_toroidal, + physics_variables.beta_toroidal_vol_avg, physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.plasma_current, @@ -4384,9 +4384,9 @@ def outplas(self): ) po.ovarre( self.outfile, - "Total toroidal beta", - "(beta_toroidal)", - physics_variables.beta_toroidal, + "Volume averaged toroidal beta", + "(beta_toroidal_vol_avg)", + physics_variables.beta_toroidal_vol_avg, "OP ", ) po.ovarre( From 5a0a2c179b16ece48a54e800fd97e14e17e17bbb Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 11:08:13 +0100 Subject: [PATCH 06/30] =?UTF-8?q?=F0=9F=94=84=20-=20Refactor=20variable=20?= =?UTF-8?q?naming=20for=20poloidal=20beta=20to=20beta=5Fpoloidal=5Fvol=5Fa?= =?UTF-8?q?vg=20for=20consistency=20across=20the=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_3_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- process/constraints.py | 8 +++--- process/data_structure/physics_variables.py | 6 ++--- process/io/mfile_comparison.py | 2 +- process/io/plot_proc.py | 2 +- process/pfcoil.py | 4 +-- process/physics.py | 26 +++++++++---------- tests/integration/test_pfcoil_int.py | 2 +- tests/unit/test_physics.py | 4 ++- 14 files changed, 34 insertions(+), 32 deletions(-) diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index 83f3dbe9a2..dbe23fe7f4 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4251E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8387E+00 Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.6055E-02 ITV - Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2531E+00 OP + Total_poloidal_beta_____________________________________________________ (beta_poloidal_vol_avg)_______________________ 1.2531E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.7123E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.4814E-03 OP Beam_ion_beta___________________________________________________________ (betanb)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index f726007bd8..e8d6f599d1 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -344,7 +344,7 @@ Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV - Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP + Total_poloidal_beta_____________________________________________________ (beta_poloidal_vol_avg)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP Beam_ion_beta___________________________________________________________ (betanb)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index 4b20967a38..ad5ea75e52 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -344,7 +344,7 @@ Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV - Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP + Total_poloidal_beta_____________________________________________________ (beta_poloidal_vol_avg)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP Beam_ion_beta___________________________________________________________ (betanb)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 19ce55885e..02b5e13eb1 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -344,7 +344,7 @@ Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV - Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP + Total_poloidal_beta_____________________________________________________ (beta_poloidal_vol_avg)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP Beam_ion_beta___________________________________________________________ (betanb)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index ab66ff6d6c..3bdd821f84 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -344,7 +344,7 @@ Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 Total_plasma_beta_______________________________________________________ (beta_total_vol_avg)________________________ 3.3648E-02 ITV - Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP + Total_poloidal_beta_____________________________________________________ (beta_poloidal_vol_avg)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP Beam_ion_beta___________________________________________________________ (betanb)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 3f6b81f70b..6592f5e179 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -205,7 +205,7 @@ Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 3.23040881535548857e-02 Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP - Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.32822381700080405e+00 OP + Total_poloidal_beta______________________________________________________ (beta_poloidal_vol_avg)________________ 1.32822381700080405e+00 OP Total_toroidal_beta______________________________________________________ (beta_toroidal_vol_avg)________________ 3.31093495352616854e-02 OP Fast_alpha_beta__________________________________________________________ (beta_fast_alpha)______________ 4.31753385900027382e-03 OP Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP diff --git a/process/constraints.py b/process/constraints.py index b34073c4d7..cfb87dcef7 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -405,7 +405,7 @@ def constraint_equation_6(): cc = ( ( data_structure.physics_variables.eps - * data_structure.physics_variables.beta_poloidal + * data_structure.physics_variables.beta_poloidal_vol_avg ) / data_structure.physics_variables.beta_poloidal_eps_max - 1.0 * data_structure.constraint_variables.fbeta_poloidal_eps @@ -415,7 +415,7 @@ def constraint_equation_6(): data_structure.physics_variables.beta_poloidal_eps_max * (1.0 - cc), ( data_structure.physics_variables.eps - * data_structure.physics_variables.beta_poloidal + * data_structure.physics_variables.beta_poloidal_vol_avg ) * cc, ) @@ -1389,14 +1389,14 @@ def constraint_equation_48(): beta_poloidal: poloidal beta """ cc = ( - data_structure.physics_variables.beta_poloidal + data_structure.physics_variables.beta_poloidal_vol_avg / data_structure.constraint_variables.beta_poloidal_max - 1.0 * data_structure.constraint_variables.fbeta_poloidal ) return ConstraintResult( cc, data_structure.constraint_variables.beta_poloidal_max * (1.0 - cc), - data_structure.physics_variables.beta_poloidal * cc, + data_structure.physics_variables.beta_poloidal_vol_avg * cc, ) diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 7d76a7be83..527b28dc55 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -233,7 +233,7 @@ """neutral beam beta component""" -beta_poloidal: float = None +beta_poloidal_vol_avg: float = None """poloidal beta""" @@ -1380,7 +1380,7 @@ def init_physics_variables(): global beta_max global beta_min global beta_beam - global beta_poloidal + global beta_poloidal_vol_avg global beta_poloidal_eps global beta_toroidal_vol_avg global beta_thermal @@ -1633,7 +1633,7 @@ def init_physics_variables(): beta_max = 0.0 beta_min = 0.0 beta_beam = 0.0 - beta_poloidal = 0.0 + beta_poloidal_vol_avg = 0.0 beta_poloidal_eps = 0.0 beta_toroidal_vol_avg = 0.0 beta_thermal = 0.0 diff --git a/process/io/mfile_comparison.py b/process/io/mfile_comparison.py index 8f0fda2022..172d8bad62 100644 --- a/process/io/mfile_comparison.py +++ b/process/io/mfile_comparison.py @@ -61,7 +61,7 @@ "plasma_current_MA", "b_plasma_toroidal_on_axis", "q95", - "beta_poloidal", + "beta_poloidal_vol_avg", "temp_plasma_electron_vol_avg_kev", "nd_plasma_electrons_vol_avg", "hfact", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 83fa0141b8..952936cfac 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2638,7 +2638,7 @@ def plot_main_plasma_information( f"Total beta,$ \\ \\beta$: {mfile_data.data['beta_total_vol_avg'].get_scan(scan):.4f}\n" f"Thermal beta,$ \\ \\beta_{{\\text{{thermal}}}}$: {mfile_data.data['beta_thermal'].get_scan(scan):.4f}\n" f"Toroidal beta,$ \\ \\beta_{{\\text{{t}}}}$: {mfile_data.data['beta_toroidal_vol_avg'].get_scan(scan):.4f}\n" - f"Poloidal beta,$ \\ \\beta_{{\\text{{p}}}}$: {mfile_data.data['beta_poloidal'].get_scan(scan):.4f}\n" + f"Poloidal beta,$ \\ \\beta_{{\\text{{p}}}}$: {mfile_data.data['beta_poloidal_vol_avg'].get_scan(scan):.4f}\n" f"Fast-alpha beta,$ \\ \\beta_{{\\alpha}}$: {mfile_data.data['beta_fast_alpha'].get_scan(scan):.4f}\n" f"Normalised total beta,$ \\ \\beta_{{\\text{{N}}}}$: {mfile_data.data['beta_norm_total'].get_scan(scan):.4f}\n" f"Normalised thermal beta,$ \\ \\beta_{{\\text{{N,thermal}}}}$: {mfile_data.data['beta_norm_thermal'].get_scan(scan):.4f}\n" diff --git a/process/pfcoil.py b/process/pfcoil.py index 4b0023c66d..45d0367798 100644 --- a/process/pfcoil.py +++ b/process/pfcoil.py @@ -409,7 +409,7 @@ def pfcoil(self): / pv.rmajor * ( math.log(8.0e0 * pv.aspect) - + pv.beta_poloidal + + pv.beta_poloidal_vol_avg + (pv.ind_plasma_internal_norm / 2.0e0) - 1.5e0 ) @@ -531,7 +531,7 @@ def pfcoil(self): / pv.rmajor * ( math.log(8.0e0 * pv.aspect) - + pv.beta_poloidal + + pv.beta_poloidal_vol_avg + (pv.ind_plasma_internal_norm / 2.0e0) - 1.5e0 ) diff --git a/process/physics.py b/process/physics.py index c7833b924d..eab72f9ba3 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1748,7 +1748,7 @@ def physics(self): ) # Calculate physics_variables.beta poloidal [-] - physics_variables.beta_poloidal = calculate_poloidal_beta( + physics_variables.beta_poloidal_vol_avg = calculate_poloidal_beta( physics_variables.b_plasma_total, physics_variables.b_plasma_poloidal_average, physics_variables.beta_total_vol_avg, @@ -1761,7 +1761,7 @@ def physics(self): ) physics_variables.beta_poloidal_eps = ( - physics_variables.beta_poloidal * physics_variables.eps + physics_variables.beta_poloidal_vol_avg * physics_variables.eps ) physics_variables.beta_thermal_poloidal = ( @@ -1988,7 +1988,7 @@ def physics(self): current_drive_variables.f_c_plasma_bootstrap_sakai = ( current_drive_variables.cboot * self.bootstrap_fraction_sakai( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, q95=physics_variables.q95, q0=physics_variables.q0, alphan=physics_variables.alphan, @@ -2001,7 +2001,7 @@ def physics(self): current_drive_variables.f_c_plasma_bootstrap_aries = ( current_drive_variables.cboot * self.bootstrap_fraction_aries( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, ind_plasma_internal_norm=physics_variables.ind_plasma_internal_norm, core_density=physics_variables.nd_plasma_electron_on_axis, average_density=physics_variables.nd_plasma_electrons_vol_avg, @@ -2012,7 +2012,7 @@ def physics(self): current_drive_variables.f_c_plasma_bootstrap_andrade = ( current_drive_variables.cboot * self.bootstrap_fraction_andrade( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, core_pressure=physics_variables.pres_plasma_on_axis, average_pressure=physics_variables.pres_plasma_vol_avg, inverse_aspect=physics_variables.eps, @@ -2021,7 +2021,7 @@ def physics(self): current_drive_variables.f_c_plasma_bootstrap_hoang = ( current_drive_variables.cboot * self.bootstrap_fraction_hoang( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, pressure_index=physics_variables.alphap, current_index=physics_variables.alphaj, inverse_aspect=physics_variables.eps, @@ -2030,7 +2030,7 @@ def physics(self): current_drive_variables.f_c_plasma_bootstrap_wong = ( current_drive_variables.cboot * self.bootstrap_fraction_wong( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, density_index=physics_variables.alphan, temperature_index=physics_variables.alphat, inverse_aspect=physics_variables.eps, @@ -2040,7 +2040,7 @@ def physics(self): current_drive_variables.bscf_gi_i = ( current_drive_variables.cboot * self.bootstrap_fraction_gi_I( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, pressure_index=physics_variables.alphap, temperature_index=physics_variables.alphat, inverse_aspect=physics_variables.eps, @@ -2053,7 +2053,7 @@ def physics(self): current_drive_variables.bscf_gi_ii = ( current_drive_variables.cboot * self.bootstrap_fraction_gi_II( - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, pressure_index=physics_variables.alphap, temperature_index=physics_variables.alphat, inverse_aspect=physics_variables.eps, @@ -2064,7 +2064,7 @@ def physics(self): current_drive_variables.cboot * self.bootstrap_fraction_sugiyama_l_mode( eps=physics_variables.eps, - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, alphan=physics_variables.alphan, alphat=physics_variables.alphat, zeff=physics_variables.zeff, @@ -2076,7 +2076,7 @@ def physics(self): current_drive_variables.cboot * self.bootstrap_fraction_sugiyama_h_mode( eps=physics_variables.eps, - beta_poloidal=physics_variables.beta_poloidal, + beta_poloidal=physics_variables.beta_poloidal_vol_avg, alphan=physics_variables.alphan, alphat=physics_variables.alphat, tbeta=physics_variables.tbeta, @@ -4378,8 +4378,8 @@ def outplas(self): po.ovarre( self.outfile, "Total poloidal beta", - "(beta_poloidal)", - physics_variables.beta_poloidal, + "(beta_poloidal_vol_avg)", + physics_variables.beta_poloidal_vol_avg, "OP ", ) po.ovarre( diff --git a/tests/integration/test_pfcoil_int.py b/tests/integration/test_pfcoil_int.py index d703022dbf..203a85feca 100644 --- a/tests/integration/test_pfcoil_int.py +++ b/tests/integration/test_pfcoil_int.py @@ -160,7 +160,7 @@ def test_pfcoil(monkeypatch, pfcoil): monkeypatch.setattr(pv, "vs_plasma_ind_ramp", 3.497e2) monkeypatch.setattr(pv, "aspect", 3.1) monkeypatch.setattr(pv, "itart", 0) - monkeypatch.setattr(pv, "beta_poloidal", 6.313e-1) + monkeypatch.setattr(pv, "beta_poloidal_vol_avg", 6.313e-1) monkeypatch.setattr(tfv, "tftmp", 4.750) monkeypatch.setattr(tfv, "dcond", np.full(9, 9.0e3)) monkeypatch.setattr(tfv, "i_tf_sup", 1) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index ef7434ce8a..aa7cc1b87c 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -618,7 +618,9 @@ def test_bootstrap_fraction_sakai(bootstrapfractionsakaiparam, monkeypatch, phys """ monkeypatch.setattr( - physics_variables, "beta_poloidal", bootstrapfractionsakaiparam.beta_poloidal + physics_variables, + "beta_poloidal_vol_avg", + bootstrapfractionsakaiparam.beta_poloidal, ) monkeypatch.setattr(physics_variables, "q95", bootstrapfractionsakaiparam.q95) From c7fd39c4c588ff6c793defc482e054b7899baf3f Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 30 Sep 2025 11:10:26 +0100 Subject: [PATCH 07/30] =?UTF-8?q?=F0=9F=94=84=20-=20Refactor=20thermal=20b?= =?UTF-8?q?eta=20variable=20naming=20to=20beta=5Fthermal=5Fvol=5Favg=20for?= =?UTF-8?q?=20consistency=20across=20the=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 6 +++--- process/io/plot_proc.py | 2 +- process/physics.py | 18 +++++++++--------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 6592f5e179..89c68152ba 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -210,7 +210,7 @@ Fast_alpha_beta__________________________________________________________ (beta_fast_alpha)______________ 4.31753385900027382e-03 OP Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.54271719682202629e-01 OP - Thermal_beta_____________________________________________________________ (beta_thermal)_________________ 2.79865542945546136e-02 OP + Thermal_beta_____________________________________________________________ (beta_thermal_vol_avg)_________________ 2.79865542945546136e-02 OP Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal)________ 1.15070290153733867e+00 OP Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 2.86841901873654617e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.42741272333601332e-01 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index dae904a56e..54494814a2 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -282,7 +282,7 @@ Fast_alpha_beta__________________________________________________________ (beta_fast_alpha)______________ 5.34272993662247321e-03 OP Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.35301246588149487e-01 OP - Thermal_beta_____________________________________________________________ (beta_thermal)_________________ 3.94876623190729900e-02 OP + Thermal_beta_____________________________________________________________ (beta_thermal_vol_avg)_________________ 3.94876623190729900e-02 OP Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal)________ 1.10150110386500244e+00 OP Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 4.09558880631420777e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.16845192112053287e-01 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 527b28dc55..fc26d88d78 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -245,7 +245,7 @@ """Volume averaged toroidal beta""" -beta_thermal: float = None +beta_thermal_vol_avg: float = None """thermal beta""" @@ -1383,7 +1383,7 @@ def init_physics_variables(): global beta_poloidal_vol_avg global beta_poloidal_eps global beta_toroidal_vol_avg - global beta_thermal + global beta_thermal_vol_avg global beta_thermal_poloidal global beta_thermal_toroidal global beta_norm_total @@ -1636,7 +1636,7 @@ def init_physics_variables(): beta_poloidal_vol_avg = 0.0 beta_poloidal_eps = 0.0 beta_toroidal_vol_avg = 0.0 - beta_thermal = 0.0 + beta_thermal_vol_avg = 0.0 beta_thermal_poloidal = 0.0 beta_thermal_toroidal = 0.0 beta_norm_total = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 952936cfac..e420057ad6 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2636,7 +2636,7 @@ def plot_main_plasma_information( textstr_beta = ( f"$\\mathbf{{Beta \\ Information:}}$\n \n" f"Total beta,$ \\ \\beta$: {mfile_data.data['beta_total_vol_avg'].get_scan(scan):.4f}\n" - f"Thermal beta,$ \\ \\beta_{{\\text{{thermal}}}}$: {mfile_data.data['beta_thermal'].get_scan(scan):.4f}\n" + f"Thermal beta,$ \\ \\beta_{{\\text{{thermal}}}}$: {mfile_data.data['beta_thermal_vol_avg'].get_scan(scan):.4f}\n" f"Toroidal beta,$ \\ \\beta_{{\\text{{t}}}}$: {mfile_data.data['beta_toroidal_vol_avg'].get_scan(scan):.4f}\n" f"Poloidal beta,$ \\ \\beta_{{\\text{{p}}}}$: {mfile_data.data['beta_poloidal_vol_avg'].get_scan(scan):.4f}\n" f"Fast-alpha beta,$ \\ \\beta_{{\\alpha}}$: {mfile_data.data['beta_fast_alpha'].get_scan(scan):.4f}\n" diff --git a/process/physics.py b/process/physics.py index eab72f9ba3..85d5bd4af4 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1754,7 +1754,7 @@ def physics(self): physics_variables.beta_total_vol_avg, ) - physics_variables.beta_thermal = ( + physics_variables.beta_thermal_vol_avg = ( physics_variables.beta_total_vol_avg - physics_variables.beta_fast_alpha - physics_variables.beta_beam @@ -1765,7 +1765,7 @@ def physics(self): ) physics_variables.beta_thermal_poloidal = ( - physics_variables.beta_thermal + physics_variables.beta_thermal_vol_avg * ( physics_variables.b_plasma_total / physics_variables.b_plasma_poloidal_average @@ -1773,7 +1773,7 @@ def physics(self): ** 2 ) physics_variables.beta_thermal_toroidal = ( - physics_variables.beta_thermal + physics_variables.beta_thermal_vol_avg * ( physics_variables.b_plasma_total / physics_variables.b_plasma_toroidal_on_axis @@ -1782,7 +1782,7 @@ def physics(self): ) physics_variables.beta_norm_thermal = ( 1.0e8 - * physics_variables.beta_thermal + * physics_variables.beta_thermal_vol_avg * physics_variables.rminor * physics_variables.b_plasma_toroidal_on_axis / physics_variables.plasma_current @@ -1806,12 +1806,12 @@ def physics(self): physics_variables.f_beta_alpha_beam_thermal = ( physics_variables.beta_fast_alpha + physics_variables.beta_beam - ) / physics_variables.beta_thermal + ) / physics_variables.beta_thermal_vol_avg # Plasma thermal energy derived from the thermal beta physics_variables.e_plasma_beta_thermal = ( 1.5e0 - * physics_variables.beta_thermal + * physics_variables.beta_thermal_vol_avg * physics_variables.b_plasma_total * physics_variables.b_plasma_total / (2.0e0 * constants.RMU0) @@ -4413,9 +4413,9 @@ def outplas(self): po.ovarre( self.outfile, - "Thermal beta", - "(beta_thermal)", - physics_variables.beta_thermal, + "Volume averaged thermal beta", + "(beta_thermal_vol_avg)", + physics_variables.beta_thermal_vol_avg, "OP ", ) po.ovarre( From da63f1ad203e30c4de7f6a57607adcec5daba512 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Thu, 16 Oct 2025 15:58:44 +0100 Subject: [PATCH 08/30] :bug: :memo: small naming fixes --- examples/data/large_tokamak_IN.DAT | 2 +- examples/data/scan_example_file_IN.DAT | 2 +- process/constraints.py | 4 +-- process/data_structure/physics_variables.py | 10 +++---- process/io/plot_proc.py | 10 +++---- process/physics.py | 2 +- .../data/large_tokamak_1_MFILE.DAT | 2 +- .../data/large_tokamak_2_MFILE.DAT | 2 +- .../data/large_tokamak_3_MFILE.DAT | 2 +- .../data/large_tokamak_4_MFILE.DAT | 2 +- .../integration/data/large_tokamak_MFILE.DAT | 2 +- tests/integration/data/scan_2D_MFILE.DAT | 30 +++++++++---------- tests/integration/data/scan_MFILE.DAT | 18 +++++------ tests/unit/data/large_tokamak_MFILE.DAT | 2 +- 14 files changed, 45 insertions(+), 45 deletions(-) diff --git a/examples/data/large_tokamak_IN.DAT b/examples/data/large_tokamak_IN.DAT index 47b92da4e4..da0321498c 100644 --- a/examples/data/large_tokamak_IN.DAT +++ b/examples/data/large_tokamak_IN.DAT @@ -23,7 +23,7 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta +ixc = 5 * beta_total_vol_avg_total_vol_avg beta_total_vol_avg =0.03 * Global power balance * diff --git a/examples/data/scan_example_file_IN.DAT b/examples/data/scan_example_file_IN.DAT index 210cf3e88a..e05c9f7a39 100644 --- a/examples/data/scan_example_file_IN.DAT +++ b/examples/data/scan_example_file_IN.DAT @@ -23,7 +23,7 @@ epsvmc = 1e-7 * Beta consistency * *------------------* icc = 1 -ixc = 5 * beta +ixc = 5 * beta_total_vol_avg beta_total_vol_avg =0.03 * Global power balance * diff --git a/process/constraints.py b/process/constraints.py index cfb87dcef7..a4ee8c8315 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -2154,13 +2154,13 @@ def constraint_equation_84(): cc = ( 1.0 - data_structure.constraint_variables.fbeta_min - * data_structure.physics_variables.beta + * data_structure.physics_variables.beta_total_vol_avg / data_structure.physics_variables.beta_min ) return ConstraintResult( cc, data_structure.physics_variables.beta_min * (1.0 - cc), - data_structure.physics_variables.beta * cc, + data_structure.physics_variables.beta_total_vol_avg * cc, ) diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index fc26d88d78..5e7eedf0b8 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -242,11 +242,11 @@ beta_toroidal_vol_avg: float = None -"""Volume averaged toroidal beta""" +"""Plasma volume averaged toroidal beta""" beta_thermal_vol_avg: float = None -"""thermal beta""" +"""Plasma volume averaged thermal beta""" beta_thermal_poloidal: float = None @@ -449,7 +449,7 @@ f_plasma_fuel_deuterium: float = None -"""deuterium fuel fraction""" +"""Plasma deuterium fuel fraction""" f_p_div_lower: float = None @@ -479,7 +479,7 @@ f_plasma_fuel_helium3: float = None -"""helium-3 fuel fraction""" +"""Plasma Helium-3 fuel fraction""" figmer: float = None @@ -505,7 +505,7 @@ f_plasma_fuel_tritium: float = None -"""tritium fuel fraction""" +"""Plasma tritium fuel fraction""" fusden_total: float = None diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index e420057ad6..8ab5eec4a4 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2635,11 +2635,11 @@ def plot_main_plasma_information( # Add beta information textstr_beta = ( f"$\\mathbf{{Beta \\ Information:}}$\n \n" - f"Total beta,$ \\ \\beta$: {mfile_data.data['beta_total_vol_avg'].get_scan(scan):.4f}\n" - f"Thermal beta,$ \\ \\beta_{{\\text{{thermal}}}}$: {mfile_data.data['beta_thermal_vol_avg'].get_scan(scan):.4f}\n" - f"Toroidal beta,$ \\ \\beta_{{\\text{{t}}}}$: {mfile_data.data['beta_toroidal_vol_avg'].get_scan(scan):.4f}\n" - f"Poloidal beta,$ \\ \\beta_{{\\text{{p}}}}$: {mfile_data.data['beta_poloidal_vol_avg'].get_scan(scan):.4f}\n" - f"Fast-alpha beta,$ \\ \\beta_{{\\alpha}}$: {mfile_data.data['beta_fast_alpha'].get_scan(scan):.4f}\n" + f"Total beta,$ \\ \\langle \\beta \\rangle$: {mfile_data.data['beta_total_vol_avg'].get_scan(scan):.4f}\n" + f"Thermal beta,$ \\ \\langle \\beta_{{\\text{{thermal}}}} \\rangle$: {mfile_data.data['beta_thermal_vol_avg'].get_scan(scan):.4f}\n" + f"Toroidal beta,$ \\ \\langle \\beta_{{\\text{{t}}}} \\rangle$: {mfile_data.data['beta_toroidal_vol_avg'].get_scan(scan):.4f}\n" + f"Poloidal beta,$ \\ \\langle \\beta_{{\\text{{p}}}} \\rangle$: {mfile_data.data['beta_poloidal_vol_avg'].get_scan(scan):.4f}\n" + f"Fast-alpha beta,$ \\ \\langle \\beta_{{\\alpha}} \\rangle$: {mfile_data.data['beta_fast_alpha'].get_scan(scan):.4f}\n" f"Normalised total beta,$ \\ \\beta_{{\\text{{N}}}}$: {mfile_data.data['beta_norm_total'].get_scan(scan):.4f}\n" f"Normalised thermal beta,$ \\ \\beta_{{\\text{{N,thermal}}}}$: {mfile_data.data['beta_norm_thermal'].get_scan(scan):.4f}\n" ) diff --git a/process/physics.py b/process/physics.py index 85d5bd4af4..3e7981f6a0 100644 --- a/process/physics.py +++ b/process/physics.py @@ -4341,7 +4341,7 @@ def outplas(self): po.ovarre( self.outfile, "Total plasma beta", - "(beta)", + "(beta_total_vol_avg)", physics_variables.beta_total_vol_avg, ) if physics_variables.i_beta_component == 0: diff --git a/tests/integration/data/large_tokamak_1_MFILE.DAT b/tests/integration/data/large_tokamak_1_MFILE.DAT index 83c9261fca..e50a5b7e96 100644 --- a/tests/integration/data/large_tokamak_1_MFILE.DAT +++ b/tests/integration/data/large_tokamak_1_MFILE.DAT @@ -342,7 +342,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP diff --git a/tests/integration/data/large_tokamak_2_MFILE.DAT b/tests/integration/data/large_tokamak_2_MFILE.DAT index 00d614f1f6..e675965e78 100644 --- a/tests/integration/data/large_tokamak_2_MFILE.DAT +++ b/tests/integration/data/large_tokamak_2_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP diff --git a/tests/integration/data/large_tokamak_3_MFILE.DAT b/tests/integration/data/large_tokamak_3_MFILE.DAT index fc2aa068b6..7ff496e209 100644 --- a/tests/integration/data/large_tokamak_3_MFILE.DAT +++ b/tests/integration/data/large_tokamak_3_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP diff --git a/tests/integration/data/large_tokamak_4_MFILE.DAT b/tests/integration/data/large_tokamak_4_MFILE.DAT index 7a27be30c2..d4752f7482 100644 --- a/tests/integration/data/large_tokamak_4_MFILE.DAT +++ b/tests/integration/data/large_tokamak_4_MFILE.DAT @@ -343,7 +343,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5961E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9805E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3648E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.3648E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2857E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4553E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.2236E-03 OP diff --git a/tests/integration/data/large_tokamak_MFILE.DAT b/tests/integration/data/large_tokamak_MFILE.DAT index 9167a5e0b5..ea29053620 100644 --- a/tests/integration/data/large_tokamak_MFILE.DAT +++ b/tests/integration/data/large_tokamak_MFILE.DAT @@ -430,7 +430,7 @@ J._Wesson_plasma_normalised_internal_inductance__________________________ (ind_plasma_internal_norm_wesson)_ 9.32164081030445235e-01 OP J._Menard_plasma_normalised_internal_inductance__________________________ (ind_plasma_internal_norm_menard)_ 1.54999999999999982e+00 OP Upper_limit_on_thermal_beta______________________________________________ (beta_max)_____________________ 4.06153354974757852e-02 OP - Total_plasma_beta________________________________________________________ (beta)_________________________ 3.18581642627421696e-02 + Total_plasma_beta________________________________________________________ beta_total_vol_avg_________________________ 3.18581642627421696e-02 Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.32441825819475811e+00 OP diff --git a/tests/integration/data/scan_2D_MFILE.DAT b/tests/integration/data/scan_2D_MFILE.DAT index 013217e935..c7d9d3b0cc 100644 --- a/tests/integration/data/scan_2D_MFILE.DAT +++ b/tests/integration/data/scan_2D_MFILE.DAT @@ -344,7 +344,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5455E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9385E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3836E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.3836E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2577E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.4772E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.3089E-03 OP @@ -1507,7 +1507,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4640E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8709E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.5277E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.5277E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2532E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.6299E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.4981E-03 OP @@ -2670,7 +2670,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.3859E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8062E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.6750E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.6750E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2490E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.7864E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.6810E-03 OP @@ -3833,7 +3833,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4009E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8186E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.6920E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.6920E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2656E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.8030E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.7217E-03 OP @@ -4996,7 +4996,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4701E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8760E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.5537E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.5537E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2668E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.6562E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.5538E-03 OP @@ -6159,7 +6159,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5501E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9423E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.4141E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.4141E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2722E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.5083E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.3887E-03 OP @@ -7322,7 +7322,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5648E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9545E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.4304E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.4304E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2886E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.5242E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.4272E-03 OP @@ -8485,7 +8485,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4926E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8947E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.5652E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.5652E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2870E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.6667E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.5983E-03 OP @@ -9648,7 +9648,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4301E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8429E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.6985E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.6985E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2891E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.8077E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.7692E-03 OP @@ -10811,7 +10811,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4346E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8466E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.7250E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.7250E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.3016E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.8348E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.8179E-03 OP @@ -11974,7 +11974,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4923E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8944E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.5948E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.5948E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2974E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.6972E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.6479E-03 OP @@ -13137,7 +13137,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5636E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9535E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.4601E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.4601E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2989E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.5548E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.4786E-03 OP @@ -14300,7 +14300,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5702E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9590E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.4830E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.4830E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.3122E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.5780E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.5223E-03 OP @@ -15463,7 +15463,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4884E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8912E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.6278E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.6278E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.3066E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.7314E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.7011E-03 OP @@ -16626,7 +16626,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.4067E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.8235E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.7817E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.7817E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.3007E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.8950E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.8907E-03 OP diff --git a/tests/integration/data/scan_MFILE.DAT b/tests/integration/data/scan_MFILE.DAT index 4d7e390f96..72d0a7c2bc 100644 --- a/tests/integration/data/scan_MFILE.DAT +++ b/tests/integration/data/scan_MFILE.DAT @@ -198,7 +198,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -1193,7 +1193,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -2188,7 +2188,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -3183,7 +3183,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -4178,7 +4178,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -5173,7 +5173,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -6168,7 +6168,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -7163,7 +7163,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP @@ -8158,7 +8158,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.5000E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 2.9256E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.0698E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.0698E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.2080E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.1498E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1786E-03 OP diff --git a/tests/unit/data/large_tokamak_MFILE.DAT b/tests/unit/data/large_tokamak_MFILE.DAT index 9dc2177a40..feed9dcc27 100644 --- a/tests/unit/data/large_tokamak_MFILE.DAT +++ b/tests/unit/data/large_tokamak_MFILE.DAT @@ -339,7 +339,7 @@ Safety_factor_on_axis___________________________________________________ (q0)__________________________ 1.0000E+00 Safety_factor_at_95%_flux_surface_______________________________________ (q95)_________________________ 3.6552E+00 ITV Cylindrical_safety_factor_(qcyl)________________________________________ (qstar)_______________________ 3.0295E+00 - Total_plasma_beta_______________________________________________________ (beta)________________________ 3.3049E-02 ITV + Total_plasma_beta_______________________________________________________ beta_total_vol_avg________________________ 3.3049E-02 ITV Total_poloidal_beta_____________________________________________________ (beta_poloidal)_______________________ 1.3036E+00 OP Total_toroidal_beta_____________________________________________________ ______________________________ 3.3909E-02 OP Fast_alpha_beta_________________________________________________________ (betaft)______________________ 4.1775E-03 OP From 3a4085fb26aa02423c7d2a245a9c4cd553944390 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 10 Oct 2025 16:45:50 +0100 Subject: [PATCH 09/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20volume=20averaged?= =?UTF-8?q?=20plasma=20pressure=20variable=20to=20thermal=20plasma=20press?= =?UTF-8?q?ure=20across=20multiple=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 4 ++-- process/physics.py | 8 ++++---- process/plasma_profiles.py | 2 +- tests/integration/data/large_tokamak_MFILE.DAT | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 89c68152ba..788755c3d6 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -232,7 +232,7 @@ Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.02466460344915771e+20 OP Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_________________________ 8.63127495812675338e+19 OP Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_on_axis)___________________________ 7.82668759018785902e+05 OP - Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_vol_avg)_____________ 2.26860509860517632e+05 OP + Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.26860509860517632e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19833068191158598e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.06084473006886912e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.58453241268011663e+19 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 54494814a2..358977f4f9 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -304,7 +304,7 @@ Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.11814263037413868e+20 OP Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_________________________ 9.41418090734859715e+19 OP Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_on_axis)___________________________ 9.10652371594472905e+05 OP - Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_vol_avg)_____________ 2.63957209157818230e+05 OP + Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.63957209157818230e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999999999999951e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.34892735750798868e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.49714589130413015e+19 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 5e7eedf0b8..5548d9a1aa 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -827,8 +827,8 @@ n_plasma_profile_elements: int = None """Number of elements in plasma profile""" -pres_plasma_vol_avg: float = None -"""Volume averaged plasma pressure (Pa)""" +pres_plasma_thermal_vol_avg: float = None +"""Volume averaged thermal plasma pressure (Pa)""" f_dd_branching_trit: float = None diff --git a/process/physics.py b/process/physics.py index 3e7981f6a0..2c91800874 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2014,7 +2014,7 @@ def physics(self): * self.bootstrap_fraction_andrade( beta_poloidal=physics_variables.beta_poloidal_vol_avg, core_pressure=physics_variables.pres_plasma_on_axis, - average_pressure=physics_variables.pres_plasma_vol_avg, + average_pressure=physics_variables.pres_plasma_thermal_vol_avg, inverse_aspect=physics_variables.eps, ) ) @@ -2609,7 +2609,7 @@ def physics(self): self.calculate_beta_norm_max_thloreus( c_beta=physics_variables.c_beta, pres_plasma_on_axis=physics_variables.pres_plasma_on_axis, - pres_plasma_vol_avg=physics_variables.pres_plasma_vol_avg, + pres_plasma_vol_avg=physics_variables.pres_plasma_thermal_vol_avg, ) ) @@ -4629,8 +4629,8 @@ def outplas(self): po.ovarre( self.outfile, "Volume averaged plasma pressure (Pa)", - "(pres_plasma_vol_avg)", - physics_variables.pres_plasma_vol_avg, + "(pres_plasma_thermal_vol_avg)", + physics_variables.pres_plasma_thermal_vol_avg, "OP ", ) # As array output is not currently supported, each element is output as a float instance diff --git a/process/plasma_profiles.py b/process/plasma_profiles.py index 2d154fa4eb..61fbeff2a1 100644 --- a/process/plasma_profiles.py +++ b/process/plasma_profiles.py @@ -320,7 +320,7 @@ def calculate_profile_factors(self) -> None: # Shall assume that the pressure profile is parabolic. Can find volume average from # profile index and core value the same as for density and temperature - physics_variables.pres_plasma_vol_avg = ( + physics_variables.pres_plasma_thermal_vol_avg = ( physics_variables.pres_plasma_on_axis / (physics_variables.alphap + 1) ) diff --git a/tests/integration/data/large_tokamak_MFILE.DAT b/tests/integration/data/large_tokamak_MFILE.DAT index ea29053620..b7690d47c7 100644 --- a/tests/integration/data/large_tokamak_MFILE.DAT +++ b/tests/integration/data/large_tokamak_MFILE.DAT @@ -466,7 +466,7 @@ Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.05329687553494565e+20 OP Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_____________ 8.86821331867437138e+19 OP Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_on_axis)___________________________ 8.42056568743616925e+05 OP - Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_vol_avg)_____________ 2.44074367751773010e+05 OP + Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.44074367751773010e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999998892791648e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.10762537507155067e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.43726858733289964e+19 OP From c1930f97c5b4e6136524fc078800f3f6365e3f5b Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 10 Oct 2025 16:49:01 +0100 Subject: [PATCH 10/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20plasma=20pressure?= =?UTF-8?q?=20variable=20to=20thermal=20plasma=20pressure=20in=20multiple?= =?UTF-8?q?=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 6 +++--- process/physics.py | 8 ++++---- process/plasma_profiles.py | 15 ++++++++------- tests/unit/test_plasma_profiles.py | 12 ++++++------ 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 788755c3d6..f5d0f439d1 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -231,7 +231,7 @@ Volume_averaged_electron_number_density_(/m3)____________________________ (nd_plasma_electrons_vol_avg)_________________________ 7.79622390002983731e+19 Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.02466460344915771e+20 OP Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_________________________ 8.63127495812675338e+19 OP - Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_on_axis)___________________________ 7.82668759018785902e+05 OP + Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_thermal_on_axis)___________________________ 7.82668759018785902e+05 OP Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.26860509860517632e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19833068191158598e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.06084473006886912e+19 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 358977f4f9..799befcd95 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -303,7 +303,7 @@ Volume_averaged_electron_number_density_(/m3)____________________________ (nd_plasma_electrons_vol_avg)_________________________ 8.50078961768999158e+19 Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.11814263037413868e+20 OP Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_________________________ 9.41418090734859715e+19 OP - Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_on_axis)___________________________ 9.10652371594472905e+05 OP + Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_thermal_on_axis)___________________________ 9.10652371594472905e+05 OP Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.63957209157818230e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999999999999951e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.34892735750798868e+19 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 5548d9a1aa..9ea94070d5 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -806,7 +806,7 @@ """margin to vertical stability""" -pres_plasma_on_axis: float = None +pres_plasma_thermal_on_axis: float = None """central total plasma pressure (Pa)""" pres_plasma_total_profile: list[float] = None @@ -1492,7 +1492,7 @@ def init_physics_variables(): global nd_plasma_electron_on_axis global nd_plasma_ions_on_axis global m_s_limit - global pres_plasma_on_axis + global pres_plasma_thermal_on_axis global pres_plasma_total_profile global pres_plasma_electron_profile global pres_plasma_ion_total_profile @@ -1745,7 +1745,7 @@ def init_physics_variables(): nd_plasma_electron_on_axis = 0.0 nd_plasma_ions_on_axis = 0.0 m_s_limit = 0.3 - pres_plasma_on_axis = 0.0 + pres_plasma_thermal_on_axis = 0.0 pres_plasma_total_profile = [] pres_plasma_electron_profile = [] pres_plasma_ion_total_profile = [] diff --git a/process/physics.py b/process/physics.py index 2c91800874..8ffdeccda9 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1628,7 +1628,7 @@ def physics(self): physics_variables.i_plasma_current, physics_variables.kappa, physics_variables.kappa95, - physics_variables.pres_plasma_on_axis, + physics_variables.pres_plasma_thermal_on_axis, physics_variables.len_plasma_poloidal, physics_variables.q95, physics_variables.rmajor, @@ -2013,7 +2013,7 @@ def physics(self): current_drive_variables.cboot * self.bootstrap_fraction_andrade( beta_poloidal=physics_variables.beta_poloidal_vol_avg, - core_pressure=physics_variables.pres_plasma_on_axis, + core_pressure=physics_variables.pres_plasma_thermal_on_axis, average_pressure=physics_variables.pres_plasma_thermal_vol_avg, inverse_aspect=physics_variables.eps, ) @@ -4622,8 +4622,8 @@ def outplas(self): po.ovarre( self.outfile, "Plasma pressure on axis (Pa)", - "(pres_plasma_on_axis)", - physics_variables.pres_plasma_on_axis, + "(pres_plasma_thermal_on_axis)", + physics_variables.pres_plasma_thermal_on_axis, "OP ", ) po.ovarre( diff --git a/process/plasma_profiles.py b/process/plasma_profiles.py index 61fbeff2a1..2408da1b22 100644 --- a/process/plasma_profiles.py +++ b/process/plasma_profiles.py @@ -27,7 +27,7 @@ class PlasmaProfile: parameterise_plasma(): Initializes the density and temperature profile averages and peak values. parabolic_paramterisation(): Parameterizes plasma profiles in the case where i_plasma_pedestal=0. pedestal_parameterisation(): Instance temperature and density profiles then integrate them, setting physics variables temp_plasma_electron_density_weighted_kev and temp_plasma_ion_density_weighted_kev. - calculate_profile_factors(): Calculate and set the central pressure (pres_plasma_on_axis) using the ideal gas law and the pressure profile index (alphap). + calculate_profile_factors(): Calculate and set the central pressure (pres_plasma_thermal_on_axis) using the ideal gas law and the pressure profile index (alphap). calculate_parabolic_profile_factors(): The gradient information for i_plasma_pedestal = 0. """ @@ -255,10 +255,10 @@ def pedestal_parameterisation(self) -> None: def calculate_profile_factors(self) -> None: """ - Calculate and set the central pressure (pres_plasma_on_axis) using the ideal gas law and the pressure profile index (alphap). + Calculate and set the central pressure (pres_plasma_thermal_on_axis) using the ideal gas law and the pressure profile index (alphap). - This method calculates the central pressure (pres_plasma_on_axis) using the ideal gas law and the pressure profile index (alphap). - It sets the value of the physics variable `pres_plasma_on_axis`. + This method calculates the central pressure (pres_plasma_thermal_on_axis) using the ideal gas law and the pressure profile index (alphap). + It sets the value of the physics variable `pres_plasma_thermal_on_axis`. Args: None @@ -269,7 +269,7 @@ def calculate_profile_factors(self) -> None: # Central pressure (Pa), from ideal gas law : p = nkT - physics_variables.pres_plasma_on_axis = ( + physics_variables.pres_plasma_thermal_on_axis = ( ( physics_variables.nd_plasma_electron_on_axis * physics_variables.temp_plasma_electron_on_axis_kev @@ -312,7 +312,7 @@ def calculate_profile_factors(self) -> None: ) # Pressure profile index (N.B. no pedestal effects included here) - # N.B. pres_plasma_on_axis is NOT equal to

* (1 + alphap), but p(rho) = n(rho)*T(rho) + # N.B. pres_plasma_thermal_on_axis is NOT equal to

* (1 + alphap), but p(rho) = n(rho)*T(rho) # and

= .T_n where <...> denotes volume-averages and T_n is the # density-weighted temperature @@ -321,7 +321,8 @@ def calculate_profile_factors(self) -> None: # Shall assume that the pressure profile is parabolic. Can find volume average from # profile index and core value the same as for density and temperature physics_variables.pres_plasma_thermal_vol_avg = ( - physics_variables.pres_plasma_on_axis / (physics_variables.alphap + 1) + physics_variables.pres_plasma_thermal_on_axis + / (physics_variables.alphap + 1) ) # Central plasma current density (A/m^2) diff --git a/tests/unit/test_plasma_profiles.py b/tests/unit/test_plasma_profiles.py index 4c5f633116..37dbe8e27a 100644 --- a/tests/unit/test_plasma_profiles.py +++ b/tests/unit/test_plasma_profiles.py @@ -141,7 +141,7 @@ class PlasmaProfilesParam(NamedTuple): temp_plasma_electron_on_axis_kev: float = 0.0 - pres_plasma_on_axis: float = 0.0 + pres_plasma_thermal_on_axis: float = 0.0 nd_plasma_separatrix_electron: float = 0.0 @@ -225,7 +225,7 @@ class PlasmaProfilesParam(NamedTuple): alphap=0.0, tbeta=2, temp_plasma_electron_on_axis_kev=0.0, - pres_plasma_on_axis=0.0, + pres_plasma_thermal_on_axis=0.0, nd_plasma_separatrix_electron=3.6421334486704804e19, temp_plasma_separatrix_kev=0.10000000000000001, pcoef=0.0, @@ -270,7 +270,7 @@ class PlasmaProfilesParam(NamedTuple): alphap=2.4500000000000002, tbeta=2, temp_plasma_electron_on_axis_kev=27.369013322953624, - pres_plasma_on_axis=868071.46874220832, + pres_plasma_thermal_on_axis=868071.46874220832, nd_plasma_separatrix_electron=3.6421334486704804e19, temp_plasma_separatrix_kev=0.10000000000000001, pcoef=1.1110842637642833, @@ -355,8 +355,8 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): monkeypatch.setattr( physics_variables, - "pres_plasma_on_axis", - plasmaprofilesparam.pres_plasma_on_axis, + "pres_plasma_thermal_on_axis", + plasmaprofilesparam.pres_plasma_thermal_on_axis, ) monkeypatch.setattr( @@ -482,7 +482,7 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): plasmaprofilesparam.expected_te0 ) - assert physics_variables.pres_plasma_on_axis == pytest.approx( + assert physics_variables.pres_plasma_thermal_on_axis == pytest.approx( plasmaprofilesparam.expected_p0 ) From f2d21e2893b37ba7a44b13806758b6667edc1d64 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 11:13:01 +0100 Subject: [PATCH 11/30] =?UTF-8?q?=F0=9F=94=84=20Update=20beta=20variable?= =?UTF-8?q?=20references=20to=20use=20total=20and=20thermal=20plasma=20pre?= =?UTF-8?q?ssure=20in=20current=20drive=20and=20physics=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process/current_drive.py | 2 +- process/physics.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/process/current_drive.py b/process/current_drive.py index b416192541..62d2d126ab 100644 --- a/process/current_drive.py +++ b/process/current_drive.py @@ -1356,7 +1356,7 @@ def cudriv(self) -> None: * current_drive_variables.feffcd, 4: lambda: self.lower_hybrid.lower_hybrid_ehst( te=physics_variables.temp_plasma_electron_vol_avg_kev, - beta=physics_variables.beta, + beta=physics_variables.beta_total_vol_avg, rmajor=physics_variables.rmajor, dene20=dene20, zeff=physics_variables.zeff, diff --git a/process/physics.py b/process/physics.py index 8ffdeccda9..38a8e3baac 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2608,7 +2608,7 @@ def physics(self): physics_variables.beta_norm_max_thloreus = ( self.calculate_beta_norm_max_thloreus( c_beta=physics_variables.c_beta, - pres_plasma_on_axis=physics_variables.pres_plasma_on_axis, + pres_plasma_on_axis=physics_variables.pres_plasma_thermal_on_axis, pres_plasma_vol_avg=physics_variables.pres_plasma_thermal_vol_avg, ) ) From 9f41512e11f66acdbe68055181dc2191db02aa9b Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 10 Oct 2025 16:42:50 +0100 Subject: [PATCH 12/30] :memo: Update plasma beta documentation: enhance definitions and clarify volume averaged beta equations --- .../physics-models/plasma_beta/plasma_beta.md | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/documentation/physics-models/plasma_beta/plasma_beta.md b/documentation/physics-models/plasma_beta/plasma_beta.md index 68b77146ac..900b83d54c 100644 --- a/documentation/physics-models/plasma_beta/plasma_beta.md +++ b/documentation/physics-models/plasma_beta/plasma_beta.md @@ -5,9 +5,19 @@ The efficiency of confinement of plasma pressure by the magnetic field is represented by the ratio: $$ -\beta = \frac{2\mu_0p}{B^2} +\beta(\rho) = \frac{2\mu_0p(\rho)}{\left(B(\rho)\right)^2} $$ +Where $\beta$ is a function of normalised minor radius across the plasma ($\rho$), due to the change in pressure and magnetic field strength. + +The standard $\beta$ term used for comparison and to represent the plasma as a whole in many calculations is the volume averaged value given by: + +$$ +\langle \beta \rangle = \frac{2\mu_0 \langle p \rangle}{\langle B \rangle^2} +$$ + +Where $\langle p \rangle$ is the volume averaged plasma pressure and $\langle B \rangle$ is the average field. + There are several different measures of this type, arising from different choices of definition and from the need to quantify different equilibrium properties. In its expanded form of magnetic field components: @@ -92,6 +102,20 @@ $$ ------------------------ +## Definitions + +### Volume averaged thermal toroidal beta + +$$ +\overbrace{\langle \beta_t \rangle}^{\texttt{beta_toroidal_thermal_vol_avg}} = \frac{2\mu_0 \langle p_{\text{thermal}} \rangle}{\underbrace{B_{\text{T,on-axis}}^2}_{\texttt{b_plasma_toroidal_on_axis}}} +$$ + +### Volume averaged thermal poloidal beta + +$$ +\langle \beta_p \rangle = \frac{2\mu_0 \langle p_{\text{thermal}} \rangle}{\langle B_{\text{P,average}} \rangle^2} +$$ + ## Troyon Beta Limit The Troyon plasma beta limit is given by[^0][^1]: From ba2efeac61d14bdd79699be55777b0c43b29fc2f Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 11:50:51 +0100 Subject: [PATCH 13/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`nd=5Falphas`=20t?= =?UTF-8?q?o=20`nd=5Fplasma=5Falphas=5Fvol=5Favg`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../physics-models/plasma_composition.md | 2 +- .../data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_3_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 8 ++-- process/io/plot_proc.py | 2 +- process/physics.py | 40 +++++++++---------- process/stellarator.py | 8 ++-- tests/unit/test_neoclassics.py | 10 +++-- tests/unit/test_physics.py | 24 ++++++----- 14 files changed, 57 insertions(+), 51 deletions(-) diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index e72859744d..3ad289d47b 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -59,7 +59,7 @@ All of the plasma composites are normally given as a fraction of the volume aver 1. **Alpha Ash Portion Calculation** - - Calculate the number density of alpha particles (`nd_alphas`) using the electron density (`nd_plasma_electrons_vol_avg`) and the alpha particle to electron ratio (`f_nd_alpha_electron`). + - Calculate the number density of alpha particles (`nd_plasma_alphas_vol_avg`) using the electron density (`nd_plasma_electrons_vol_avg`) and the alpha particle to electron ratio (`f_nd_alpha_electron`). - `f_nd_alpha_electron` can be set as an iteration variable (`ixc = 109`) or set directly. $$ diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index dbe23fe7f4..380e8c3209 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -372,7 +372,7 @@ Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.2127E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.5392E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6024E+16 OP - Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_alphas)_______________________ 6.6709E+18 OP + Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.6709E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8502E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4748E+19 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index e8d6f599d1..1b170eee1e 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -373,7 +373,7 @@ Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP - Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_alphas)_______________________ 6.7723E+18 OP + Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index ad5ea75e52..a679c3b049 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -373,7 +373,7 @@ Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP - Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_alphas)_______________________ 6.7723E+18 OP + Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 02b5e13eb1..64693f8b86 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -373,7 +373,7 @@ Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP - Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_alphas)_______________________ 6.7723E+18 OP + Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protonstons)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index 3bdd821f84..e1d3276d72 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -373,7 +373,7 @@ Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP - Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_alphas)_______________________ 6.7723E+18 OP + Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index f5d0f439d1..d69e96c0f0 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -237,7 +237,7 @@ Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.06084473006886912e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.58453241268011663e+19 OP Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 5.43985672856892960e+16 OP - Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_alphas)____________________ 4.69634891516571443e+18 OP + Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 4.69634891516571443e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 6.02387639886502110e-02 Proton_number_density_(/m3)______________________________________________ (nd_protons)___________________ 1.23756914361185080e+16 OP Proton_number_density_/_electron_number_density__________________________ (f_nd_protium_electrons)_______ 0.00000000000000000e+00 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 799befcd95..7d71c4009e 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -309,7 +309,7 @@ Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.34892735750798868e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.49714589130413015e+19 OP Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 6.41695061162086560e+16 OP - Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_alphas)____________________ 8.43080585227756646e+18 OP + Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 8.43080585227756646e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 9.91767380612879751e-02 Proton_number_density_(/m3)______________________________________________ (nd_protons)___________________ 2.28393036448186680e+16 OP Proton_number_density_/_electron_number_density__________________________ (f_nd_protium_electrons)_______ 0.00000000000000000e+00 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 9ea94070d5..cb709915b9 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -346,8 +346,8 @@ """density limit (/m3) as calculated using various models""" -nd_alphas: float = None -"""thermal alpha density (/m3)""" +nd_plasma_alphas_vol_avg: float = None +"""Plasma volume averaged thermal alpha density (/m3)""" nd_beam_ions: float = None @@ -1408,7 +1408,7 @@ def init_physics_variables(): global dlamee global dlamie global dlimit - global nd_alphas + global nd_plasma_alphas_vol_avg global nd_beam_ions global nd_beam_ions_out global beta_norm_max @@ -1661,7 +1661,7 @@ def init_physics_variables(): dlamee = 0.0 dlamie = 0.0 dlimit = np.zeros(8, dtype=np.float64) - nd_alphas = 0.0 + nd_plasma_alphas_vol_avg = 0.0 nd_beam_ions = 0.0 nd_beam_ions_out = 0.0 beta_norm_max = 3.5 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 8ab5eec4a4..3bce2b586c 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3680,7 +3680,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): r"$\langle n_{\text{fuel}} \rangle $: " f"{mfile_data.data['nd_fuel_ions'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{alpha}} \rangle $: " - f"{mfile_data.data['nd_alphas'].get_scan(scan):.3e} m$^{{-3}}$", + f"{mfile_data.data['nd_plasma_alphas_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{impurities}} \rangle $: " f"{mfile_data.data['nd_impurities'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{protons}} \rangle $:" diff --git a/process/physics.py b/process/physics.py index 38a8e3baac..ae2bae9dd1 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1597,7 +1597,7 @@ def physics(self): physics_variables.m_ions_total_amu, physics_variables.nd_ions_total, physics_variables.nd_fuel_ions, - physics_variables.nd_alphas, + physics_variables.nd_plasma_alphas_vol_avg, physics_variables.vol_plasma, physics_variables.nd_plasma_electrons_vol_avg, ) @@ -2571,7 +2571,7 @@ def physics(self): physics_variables.fusden_alpha_total, physics_variables.plasma_current, sbar, - physics_variables.nd_alphas, + physics_variables.nd_plasma_alphas_vol_avg, physics_variables.t_energy_confinement, physics_variables.vol_plasma, ) @@ -3221,7 +3221,7 @@ def plasma_composition() -> None: """ # Alpha ash portion - physics_variables.nd_alphas = ( + physics_variables.nd_plasma_alphas_vol_avg = ( physics_variables.nd_plasma_electrons_vol_avg * physics_variables.f_nd_alpha_electron ) @@ -3237,14 +3237,14 @@ def plasma_composition() -> None: physics_variables.nd_protons = max( physics_variables.f_nd_protium_electrons * physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_alphas + physics_variables.nd_plasma_alphas_vol_avg * (physics_variables.f_plasma_fuel_helium3 + 1.0e-3), ) # rough estimate else: physics_variables.nd_protons = max( physics_variables.f_nd_protium_electrons * physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_alphas + physics_variables.nd_plasma_alphas_vol_avg * physics_variables.proton_rate_density / physics_variables.fusden_alpha_total, ) @@ -3280,7 +3280,7 @@ def plasma_composition() -> None: # znfuel is the sum of Zi.ni for the three fuel ions znfuel = ( physics_variables.nd_plasma_electrons_vol_avg - - 2.0 * physics_variables.nd_alphas + - 2.0 * physics_variables.nd_plasma_alphas_vol_avg - physics_variables.nd_protons - physics_variables.nd_beam_ions - znimp @@ -3336,7 +3336,7 @@ def plasma_composition() -> None: # Total ion density physics_variables.nd_ions_total = ( physics_variables.nd_fuel_ions - + physics_variables.nd_alphas + + physics_variables.nd_plasma_alphas_vol_avg + physics_variables.nd_protons + physics_variables.nd_beam_ions + physics_variables.nd_impurities @@ -3427,7 +3427,7 @@ def plasma_composition() -> None: # Average mass of all ions physics_variables.m_ions_total_amu = ( (physics_variables.m_fuel_amu * physics_variables.nd_fuel_ions) - + (constants.M_ALPHA_AMU * physics_variables.nd_alphas) + + (constants.M_ALPHA_AMU * physics_variables.nd_plasma_alphas_vol_avg) + (physics_variables.nd_protons * constants.M_PROTON_AMU) + (physics_variables.m_beam_amu * physics_variables.nd_beam_ions) ) @@ -3464,7 +3464,7 @@ def plasma_composition() -> None: * physics_variables.nd_fuel_ions / constants.M_HELION_AMU ) - + (4.0 * physics_variables.nd_alphas / constants.M_ALPHA_AMU) + + (4.0 * physics_variables.nd_plasma_alphas_vol_avg / constants.M_ALPHA_AMU) + (physics_variables.nd_protons / constants.M_PROTON_AMU) + ( (1.0 - current_drive_variables.f_beam_tritium) @@ -3501,7 +3501,7 @@ def phyaux( fusden_alpha_total: float, plasma_current: float, sbar: float, - nd_alphas: float, + nd_plasma_alphas_vol_avg: float, t_energy_confinement: float, vol_plasma: float, ) -> tuple[float, float, float, float, float, float, float, float]: @@ -3516,7 +3516,7 @@ def phyaux( fusden_alpha_total (float): Alpha particle production rate (/m3/s). plasma_current (float): Plasma current (A). sbar (float): Exponent for aspect ratio (normally 1). - nd_alphas (float): Alpha ash density (/m3). + nd_plasma_alphas_vol_avg (float): Alpha ash density (/m3). t_energy_confinement (float): Global energy confinement time (s). vol_plasma (float): Plasma volume (m3). @@ -3545,7 +3545,7 @@ def phyaux( # Alpha particle confinement time (s) # Number of alphas / alpha production rate if fusden_alpha_total != 0.0: - t_alpha_confinement = nd_alphas / fusden_alpha_total + t_alpha_confinement = nd_plasma_alphas_vol_avg / fusden_alpha_total else: # only likely if DD is only active fusion reaction t_alpha_confinement = 0.0 @@ -3561,8 +3561,8 @@ def phyaux( # Remember that unburnt fuel-ion pairs/m3 = 0.5 * unburnt fuel-ions/m3 if physics_variables.burnup_in <= 1.0e-9: burnup = ( - nd_alphas - / (nd_alphas + 0.5 * nd_fuel_ions) + nd_plasma_alphas_vol_avg + / (nd_plasma_alphas_vol_avg + 0.5 * nd_fuel_ions) / physics_variables.tauratio ) else: @@ -4697,8 +4697,8 @@ def outplas(self): po.ovarre( self.outfile, "Helium ion number density (thermalised ions only) (/m3)", - "(nd_alphas)", - physics_variables.nd_alphas, + "(nd_plasma_alphas_vol_avg)", + physics_variables.nd_plasma_alphas_vol_avg, "OP ", ) po.ovarre( @@ -8502,7 +8502,7 @@ def calculate_plasma_masses( m_ions_total_amu: float, nd_ions_total: float, nd_fuel_ions: float, - nd_alphas: float, + nd_plasma_alphas_vol_avg: float, vol_plasma: float, nd_plasma_electrons_vol_avg: float, ) -> tuple[float, float, float, float, float]: @@ -8517,8 +8517,8 @@ def calculate_plasma_masses( :type nd_ions_total: float :param nd_fuel_ions: Fuel ion density (/m3). :type nd_fuel_ions: float - :param nd_alphas: Alpha ash density (/m3). - :type nd_alphas: float + :param nd_plasma_alphas_vol_avg: Alpha ash density (/m3). + :type nd_plasma_alphas_vol_avg: float :param vol_plasma: Plasma volume (m3). :type vol_plasma: float :param nd_plasma_electrons_vol_avg: Volume averaged electron density (/m3). @@ -8537,7 +8537,7 @@ def calculate_plasma_masses( nd_ions_total * vol_plasma ) - m_plasma_alpha = (nd_alphas * vol_plasma) * constants.ALPHA_MASS + m_plasma_alpha = (nd_plasma_alphas_vol_avg * vol_plasma) * constants.ALPHA_MASS m_plasma_electron = constants.ELECTRON_MASS * ( nd_plasma_electrons_vol_avg * vol_plasma diff --git a/process/stellarator.py b/process/stellarator.py index 4d16b0f6b9..a38db6115c 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4663,7 +4663,7 @@ def stphys(self, output): physics_variables.fusden_alpha_total, physics_variables.plasma_current, sbar, - physics_variables.nd_alphas, + physics_variables.nd_plasma_alphas_vol_avg, physics_variables.t_energy_confinement, physics_variables.vol_plasma, ) @@ -5418,7 +5418,7 @@ def init_profile_values_from_PROCESS(self, rho): * (1 - rho**2) ** physics_variables.alphan ) densa = ( - physics_variables.nd_alphas + physics_variables.nd_plasma_alphas_vol_avg * (1 + physics_variables.alphan) * (1 - rho**2) ** physics_variables.alphan ) @@ -5499,7 +5499,7 @@ def init_profile_values_from_PROCESS(self, rho): * 1.0 / physics_variables.rminor * rho - * physics_variables.nd_alphas + * physics_variables.nd_plasma_alphas_vol_avg * (1 + physics_variables.alphan) * (1.0 - rho**2) ** (physics_variables.alphan - 1.0) * physics_variables.alphan @@ -5633,7 +5633,7 @@ def neoclassics_calc_nu_star_fromT(self, iota): physics_variables.nd_fuel_ions * physics_variables.f_plasma_fuel_deuterium, physics_variables.nd_fuel_ions * (1 - physics_variables.f_plasma_fuel_deuterium), - physics_variables.nd_alphas, + physics_variables.nd_plasma_alphas_vol_avg, ]) mass = np.array([ diff --git a/tests/unit/test_neoclassics.py b/tests/unit/test_neoclassics.py index 8662f06b40..86af0afc77 100644 --- a/tests/unit/test_neoclassics.py +++ b/tests/unit/test_neoclassics.py @@ -25,7 +25,7 @@ class InitNeoclassicsParam(NamedTuple): temp_plasma_ion_on_axis_kev: Any = None nd_plasma_ions_on_axis: Any = None f_plasma_fuel_deuterium: Any = None - nd_alphas: Any = None + nd_plasma_alphas_vol_avg: Any = None rminor: Any = None rmajor: Any = None b_plasma_toroidal_on_axis: Any = None @@ -74,7 +74,7 @@ class InitNeoclassicsParam(NamedTuple): temp_plasma_ion_on_axis_kev=12.579710000000002, nd_plasma_ions_on_axis=2.3930858160000005e20, f_plasma_fuel_deuterium=0.5, - nd_alphas=2.9820384000000004e19, + nd_plasma_alphas_vol_avg=2.9820384000000004e19, rminor=1.7993820274145451, rmajor=22.16, b_plasma_toroidal_on_axis=5.2400000000000002, @@ -1000,7 +1000,11 @@ def test_init_neoclassics(initneoclassicsparam, monkeypatch, neoclassics): "f_plasma_fuel_deuterium", initneoclassicsparam.f_plasma_fuel_deuterium, ) - monkeypatch.setattr(physics_variables, "nd_alphas", initneoclassicsparam.nd_alphas) + monkeypatch.setattr( + physics_variables, + "nd_plasma_alphas_vol_avg", + initneoclassicsparam.nd_plasma_alphas_vol_avg, + ) monkeypatch.setattr(physics_variables, "rminor", initneoclassicsparam.rminor) monkeypatch.setattr(physics_variables, "rmajor", initneoclassicsparam.rmajor) monkeypatch.setattr( diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index aa7cc1b87c..288bf19622 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1414,7 +1414,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_helium3: Any = None - nd_alphas: Any = None + nd_plasma_alphas_vol_avg: Any = None nd_plasma_electrons_vol_avg: Any = None @@ -1556,7 +1556,7 @@ class PlasmaCompositionParam(NamedTuple): alphan=1, nd_beam_ions=0, f_plasma_fuel_helium3=0, - nd_alphas=0, + nd_plasma_alphas_vol_avg=0, nd_plasma_electrons_vol_avg=7.5e19, nd_protons=0, iscz=0, @@ -1674,7 +1674,7 @@ class PlasmaCompositionParam(NamedTuple): alphan=1, nd_beam_ions=0, f_plasma_fuel_helium3=0, - nd_alphas=7.5e18, + nd_plasma_alphas_vol_avg=7.5e18, nd_plasma_electrons_vol_avg=7.5e19, nd_protons=7500000000000000, iscz=0, @@ -1881,7 +1881,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "nd_alphas", plasmacompositionparam.nd_alphas + physics_variables, + "nd_plasma_alphas_vol_avg", + plasmacompositionparam.nd_plasma_alphas_vol_avg, ) monkeypatch.setattr( @@ -1966,7 +1968,7 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): plasmacompositionparam.expected_m_beam_amu ) - assert physics_variables.nd_alphas == pytest.approx( + assert physics_variables.nd_plasma_alphas_vol_avg == pytest.approx( plasmacompositionparam.expected_nd_alphas ) @@ -2143,7 +2145,7 @@ class PhyauxParam(NamedTuple): nd_fuel_ions: Any = None - nd_alphas: Any = None + nd_plasma_alphas_vol_avg: Any = None fusden_total: Any = None @@ -2184,7 +2186,7 @@ class PhyauxParam(NamedTuple): nd_plasma_electrons_vol_avg=7.5e19, te=12.569, nd_fuel_ions=5.8589175702454272e19, - nd_alphas=7.5e18, + nd_plasma_alphas_vol_avg=7.5e18, fusden_total=1.9852091609123786e17, fusden_alpha_total=1.973996644759543e17, plasma_current=18398455.678867526, @@ -2207,7 +2209,7 @@ class PhyauxParam(NamedTuple): nd_plasma_electrons_vol_avg=7.5e19, te=12.569, nd_fuel_ions=5.8576156204039725e19, - nd_alphas=7.5e18, + nd_plasma_alphas_vol_avg=7.5e18, fusden_total=1.9843269653375773e17, fusden_alpha_total=1.9731194318497056e17, plasma_current=18398455.678867526, @@ -2257,7 +2259,7 @@ def test_phyaux(phyauxparam, monkeypatch, physics): nd_plasma_electrons_vol_avg=phyauxparam.nd_plasma_electrons_vol_avg, te=phyauxparam.te, nd_fuel_ions=phyauxparam.nd_fuel_ions, - nd_alphas=phyauxparam.nd_alphas, + nd_plasma_alphas_vol_avg=phyauxparam.nd_plasma_alphas_vol_avg, fusden_total=phyauxparam.fusden_total, fusden_alpha_total=phyauxparam.fusden_alpha_total, plasma_current=phyauxparam.plasma_current, @@ -3347,7 +3349,7 @@ def test_calculate_plasma_masses(): m_ions_total_amu = 3.0 nd_ions_total = 1.0e20 nd_fuel_ions = 0.8e20 - nd_alphas = 0.1e20 + nd_plasma_alphas_vol_avg = 0.1e20 vol_plasma = 100.0 nd_plasma_electrons_vol_avg = 1.0e20 @@ -3362,7 +3364,7 @@ def test_calculate_plasma_masses(): m_ions_total_amu=m_ions_total_amu, nd_ions_total=nd_ions_total, nd_fuel_ions=nd_fuel_ions, - nd_alphas=nd_alphas, + nd_plasma_alphas_vol_avg=nd_plasma_alphas_vol_avg, vol_plasma=vol_plasma, nd_plasma_electrons_vol_avg=nd_plasma_electrons_vol_avg, ) From 7f7edf545909d5fed6510867f745b3616fa0d0c2 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 11:54:25 +0100 Subject: [PATCH 14/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`nd=5Fprotons`=20?= =?UTF-8?q?to=20`nd=5Fplasma=5Fprotons=5Fvol=5Favg`=20across=20multiple=20?= =?UTF-8?q?files=20for=20consistency=20in=20plasma=20density=20calculation?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../physics-models/plasma_composition.md | 6 +++--- .../data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 8 ++++---- process/io/plot_proc.py | 2 +- process/physics.py | 20 +++++++++---------- tests/unit/test_physics.py | 12 ++++++----- 11 files changed, 31 insertions(+), 29 deletions(-) diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index 3ad289d47b..c920612b0f 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -68,19 +68,19 @@ All of the plasma composites are normally given as a fraction of the volume aver 2. **Protons Calculation** - - The calculation of proton density (`nd_protons`) depends on whether the alpha rate density has been calculated. This should only happen in the first function call as the rates are calculated later on in the code. + - The calculation of proton density (`nd_plasma_protons_vol_avg`) depends on whether the alpha rate density has been calculated. This should only happen in the first function call as the rates are calculated later on in the code. - If the alpha rate density is not yet calculated, use a rough estimate. $$ - \texttt{nd_protons} | n_{\text{p}} = \\ + \texttt{nd_plasma_protons_vol_avg} | n_{\text{p}} = \\ \text{max}\left[\texttt{f_nd_protium_electrons} \times n_{\text{e}}, n_{\alpha}\times \left(f_{\text{3He}} + 0.001\right)\right] $$ - Otherwise, use the calculated proton rate density. $$ - \texttt{nd_protons} | n_{\text{p}} = \\ + \texttt{nd_plasma_protons_vol_avg} | n_{\text{p}} = \\ \text{max}\left[\texttt{f_nd_protium_electrons} \times n_{\text{e}}, n_{\alpha}\times \frac{r_{\text{p}}}{r_{\alpha,\text{total}}}\right] $$ diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index 380e8c3209..78130f24e3 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -373,7 +373,7 @@ Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.5392E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6024E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.6709E+18 OP - Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8502E+16 OP + Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8502E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4748E+19 OP Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4748E+19 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index 1b170eee1e..b848bc90df 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -374,7 +374,7 @@ Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP - Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8963E+16 OP + Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index a679c3b049..176d478074 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -374,7 +374,7 @@ Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP - Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8963E+16 OP + Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index e1d3276d72..60e615b138 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -374,7 +374,7 @@ Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP - Proton_density_(/m3)____________________________________________________ (nd_protons)______________________ 1.8963E+16 OP + Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index d69e96c0f0..685d4b1eed 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -239,7 +239,7 @@ Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 5.43985672856892960e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 4.69634891516571443e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 6.02387639886502110e-02 - Proton_number_density_(/m3)______________________________________________ (nd_protons)___________________ 1.23756914361185080e+16 OP + Proton_number_density_(/m3)______________________________________________ (nd_plasma_protons_vol_avg)___________________ 1.23756914361185080e+16 OP Proton_number_density_/_electron_number_density__________________________ (f_nd_protium_electrons)_______ 0.00000000000000000e+00 OP Hot_beam_ion_number_density_(/m3)________________________________________ (nd_beam_ions)_________________ 0.00000000000000000e+00 OP Hot_beam_ion_number_density_/_electron_density___________________________ (f_nd_beam_electron)___________ 0.00000000000000000e+00 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 7d71c4009e..be4fe44a48 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -311,7 +311,7 @@ Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 6.41695061162086560e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 8.43080585227756646e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 9.91767380612879751e-02 - Proton_number_density_(/m3)______________________________________________ (nd_protons)___________________ 2.28393036448186680e+16 OP + Proton_number_density_(/m3)______________________________________________ (nd_plasma_protons_vol_avg)___________________ 2.28393036448186680e+16 OP Proton_number_density_/_electron_number_density__________________________ (f_nd_protium_electrons)_______ 0.00000000000000000e+00 OP Hot_beam_ion_number_density_(/m3)________________________________________ (nd_beam_ions)_________________ 0.00000000000000000e+00 OP Hot_beam_ion_number_density_/_electron_density___________________________ (f_nd_beam_electron)___________ 0.00000000000000000e+00 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index cb709915b9..5047465180 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -394,8 +394,8 @@ """line averaged electron density (/m3)""" -nd_protons: float = None -"""proton ash density (/m3)""" +nd_plasma_protons_vol_avg: float = None +"""Plasma volume averaged proton ash density (/m3)""" ntau: float = None @@ -1420,7 +1420,7 @@ def init_physics_variables(): global dnelimt global nd_ions_total global nd_electron_line - global nd_protons + global nd_plasma_protons_vol_avg global ntau global nTtau global nd_impurities @@ -1673,7 +1673,7 @@ def init_physics_variables(): dnelimt = 0.0 nd_ions_total = 0.0 nd_electron_line = 0.0 - nd_protons = 0.0 + nd_plasma_protons_vol_avg = 0.0 ntau = 0.0 nTtau = 0.0 nd_impurities = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 3bce2b586c..d09bc2f3c8 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3684,7 +3684,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): r"$\langle n_{\text{impurities}} \rangle $: " f"{mfile_data.data['nd_impurities'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{protons}} \rangle $:" - f"{mfile_data.data['nd_protons'].get_scan(scan):.3e} m$^{{-3}}$", + f"{mfile_data.data['nd_plasma_protons_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", )) prof.text( diff --git a/process/physics.py b/process/physics.py index ae2bae9dd1..ccf4c70a6c 100644 --- a/process/physics.py +++ b/process/physics.py @@ -3234,14 +3234,14 @@ def plasma_composition() -> None: # Issue #557 Allow f_nd_protium_electrons impurity to be specified: 'f_nd_protium_electrons' # This will override the calculated value which is a minimum. if physics_variables.fusden_alpha_total < 1.0e-6: # not calculated yet... - physics_variables.nd_protons = max( + physics_variables.nd_plasma_protons_vol_avg = max( physics_variables.f_nd_protium_electrons * physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_plasma_alphas_vol_avg * (physics_variables.f_plasma_fuel_helium3 + 1.0e-3), ) # rough estimate else: - physics_variables.nd_protons = max( + physics_variables.nd_plasma_protons_vol_avg = max( physics_variables.f_nd_protium_electrons * physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_plasma_alphas_vol_avg @@ -3281,7 +3281,7 @@ def plasma_composition() -> None: znfuel = ( physics_variables.nd_plasma_electrons_vol_avg - 2.0 * physics_variables.nd_plasma_alphas_vol_avg - - physics_variables.nd_protons + - physics_variables.nd_plasma_protons_vol_avg - physics_variables.nd_beam_ions - znimp ) @@ -3302,7 +3302,7 @@ def plasma_composition() -> None: impurity_radiation_module.f_nd_impurity_electron_array[ impurity_radiation.element2index("H_") ] = ( - physics_variables.nd_protons + physics_variables.nd_plasma_protons_vol_avg + ( physics_variables.f_plasma_fuel_deuterium + physics_variables.f_plasma_fuel_tritium @@ -3337,7 +3337,7 @@ def plasma_composition() -> None: physics_variables.nd_ions_total = ( physics_variables.nd_fuel_ions + physics_variables.nd_plasma_alphas_vol_avg - + physics_variables.nd_protons + + physics_variables.nd_plasma_protons_vol_avg + physics_variables.nd_beam_ions + physics_variables.nd_impurities ) @@ -3428,7 +3428,7 @@ def plasma_composition() -> None: physics_variables.m_ions_total_amu = ( (physics_variables.m_fuel_amu * physics_variables.nd_fuel_ions) + (constants.M_ALPHA_AMU * physics_variables.nd_plasma_alphas_vol_avg) - + (physics_variables.nd_protons * constants.M_PROTON_AMU) + + (physics_variables.nd_plasma_protons_vol_avg * constants.M_PROTON_AMU) + (physics_variables.m_beam_amu * physics_variables.nd_beam_ions) ) for imp in range(impurity_radiation_module.N_IMPURITIES): @@ -3465,7 +3465,7 @@ def plasma_composition() -> None: / constants.M_HELION_AMU ) + (4.0 * physics_variables.nd_plasma_alphas_vol_avg / constants.M_ALPHA_AMU) - + (physics_variables.nd_protons / constants.M_PROTON_AMU) + + (physics_variables.nd_plasma_protons_vol_avg / constants.M_PROTON_AMU) + ( (1.0 - current_drive_variables.f_beam_tritium) * physics_variables.nd_beam_ions @@ -4709,9 +4709,9 @@ def outplas(self): ) po.ovarre( self.outfile, - "Proton number density (/m3)", - "(nd_protons)", - physics_variables.nd_protons, + "Plasma volume averaged proton number density (/m3)", + "(nd_plasma_protons_vol_avg)", + physics_variables.nd_plasma_protons_vol_avg, "OP ", ) po.ovarre( diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index 288bf19622..6dd3893ed9 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1418,7 +1418,7 @@ class PlasmaCompositionParam(NamedTuple): nd_plasma_electrons_vol_avg: Any = None - nd_protons: Any = None + nd_plasma_protons_vol_avg: Any = None iscz: Any = None @@ -1558,7 +1558,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_helium3=0, nd_plasma_alphas_vol_avg=0, nd_plasma_electrons_vol_avg=7.5e19, - nd_protons=0, + nd_plasma_protons_vol_avg=0, iscz=0, err242=0, err243=0, @@ -1676,7 +1676,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_helium3=0, nd_plasma_alphas_vol_avg=7.5e18, nd_plasma_electrons_vol_avg=7.5e19, - nd_protons=7500000000000000, + nd_plasma_protons_vol_avg=7500000000000000, iscz=0, err242=0, err243=0, @@ -1893,7 +1893,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "nd_protons", plasmacompositionparam.nd_protons + physics_variables, + "nd_plasma_protons_vol_avg", + plasmacompositionparam.nd_plasma_protons_vol_avg, ) monkeypatch.setattr(physics_variables, "iscz", plasmacompositionparam.iscz) @@ -1972,7 +1974,7 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): plasmacompositionparam.expected_nd_alphas ) - assert physics_variables.nd_protons == pytest.approx( + assert physics_variables.nd_plasma_protons_vol_avg == pytest.approx( plasmacompositionparam.expected_nd_protons ) From d4cc3a62ce849dce5ce04d0382289d1c34f14fd8 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 13:22:48 +0100 Subject: [PATCH 15/30] :art: Add output for ratio of electron density weighted temperature to volume averaged temperature in physics module --- process/io/plot_proc.py | 7 +++++-- process/physics.py | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index d09bc2f3c8..b3a37ce23b 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3820,7 +3820,8 @@ def plot_t_profiles(prof, demo_ranges, mfile_data, scan): te = mfile_data.data["temp_plasma_electron_vol_avg_kev"].get_scan(scan) # Add text box with temperature profile parameters textstr_temperature = "\n".join(( - rf"$\langle T_{{\text{{e}}}} \rangle$: {mfile_data.data['temp_plasma_electron_vol_avg_kev'].get_scan(scan):.3f} keV", + rf"$\langle T_{{\text{{e}}}} \rangle_\text{{V}}$: {mfile_data.data['temp_plasma_electron_vol_avg_kev'].get_scan(scan):.3f} keV" + rf"$\hspace{{3}} \langle T_{{\text{{e}}}} \rangle_\text{{n}}$: {mfile_data.data['temp_plasma_electron_density_weighted_kev'].get_scan(scan):.3f} keV", rf"$T_{{\text{{e,0}}}}$: {te0:.3f} keV" rf"$\hspace{{4}} \alpha_{{\text{{T}}}}$: {alphat:.3f}", rf"$T_{{\text{{e,ped}}}}$: {temp_plasma_pedestal_kev:.3f} keV" @@ -3829,7 +3830,9 @@ def plot_t_profiles(prof, demo_ranges, mfile_data, scan): rf"$\rho_{{\text{{ped,T}}}}$: {radius_plasma_pedestal_temp_norm:.3f}" r"$ \hspace{6} \frac{T_{e,0}}{\langle T_e \rangle}$: " f"{te0 / te:.3f}", - rf"$T_{{\text{{e,sep}}}}$: {temp_plasma_separatrix_kev:.3f} keV", + rf"$T_{{\text{{e,sep}}}}$: {temp_plasma_separatrix_kev:.3f} keV" + r"$ \hspace{4} \frac{{{\langle T_e \rangle_n}}}{{{\langle T_e \rangle_V}}}$: " + f"{mfile_data.data['pcoef'].get_scan(scan):.3f}", )) props_temperature = {"boxstyle": "round", "facecolor": "wheat", "alpha": 0.5} diff --git a/process/physics.py b/process/physics.py index ccf4c70a6c..4cc918f28d 100644 --- a/process/physics.py +++ b/process/physics.py @@ -4599,6 +4599,13 @@ def outplas(self): physics_variables.temp_plasma_electron_density_weighted_kev, "OP ", ) + po.ovarrf( + self.outfile, + "Ratio of electron density weighted temp. to volume averaged temp.", + "(pcoef)", + physics_variables.pcoef, + "OP ", + ) po.ovarre( self.outfile, "Volume averaged electron number density (/m3)", From 6aa2f1a665c584eb2cab6ca90998cd11dfacdec4 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 13:56:28 +0100 Subject: [PATCH 16/30] :memo: Clarify documentation on density weighted temperature and update plasma pressure variable descriptions --- documentation/physics-models/plasma_beta/plasma_beta.md | 8 +++++++- process/constraints.py | 2 ++ process/data_structure/physics_variables.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/documentation/physics-models/plasma_beta/plasma_beta.md b/documentation/physics-models/plasma_beta/plasma_beta.md index 900b83d54c..28872a7355 100644 --- a/documentation/physics-models/plasma_beta/plasma_beta.md +++ b/documentation/physics-models/plasma_beta/plasma_beta.md @@ -374,7 +374,13 @@ This constraint can be activated by stating `icc = 1` in the input file. Ensures the relationship between $\beta$, density, temperature and total magnetic field is withheld by checking the fixed input or iteration variable $\mathtt{beta}$ is consistent in value with the rest of the physics parameters $$ -\mathtt{beta_total_vol_avg} \equiv \frac{2\mu_0 \langle n_{\text{e}}T_{\text{e}}+n_{\text{i}}T_{\text{i}}\rangle}{B^2} + \beta_{\alpha} + \beta_{\text{beam}} +\texttt{beta_total_vol_avg} \equiv \frac{2\mu_0 \langle n_{\text{e}}T_{\text{e}}+n_{\text{i}}T_{\text{i}}\rangle}{B^2} + \beta_{\alpha} + \beta_{\text{beam}} +$$ + +Here the calculation of the volume averaged pressure of the ions and electrons has to use the density weighted temperature for each. This is because $\langle nT \rangle_{\text{V}} \neq \langle n \rangle_{\text{V}} \langle T \rangle_{\text{V}}$, where $\text{V}$ denotes the volume averaged value. The true value is, $\langle nT \rangle_{\text{V}} = \langle n \rangle_{\text{V}} \langle T \rangle_{\text{n}}$, where $\text{n}$ is the density weighted averaged. For example: + +$$ +\langle n_{\text{e}}T_{\text{e}} \rangle_{\text{V}} = \overbrace{\langle n_{\text{e}} \rangle_{\text{V}}}^{\texttt{nd_plasma_electrons_vol_avg}} \times \overbrace{\langle T_{\text{e}} \rangle_{\text{n}}}^{\texttt{temp_plasma_electron_density_weighted_kev}} $$ **It is highly recommended to always have this constraint on as it is a global consistency checker** diff --git a/process/constraints.py b/process/constraints.py index a4ee8c8315..e9b1048635 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -136,6 +136,8 @@ def constraint_equation_1(): T_i: density weighted average ion temperature [keV] B_{tot}: total toroidal + poloidal field [T] """ + + # Density weighted temperature is used here as 〈nT〉 != 〈n〉_V * 〈T〉_V cc = ( 1.0 - ( diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 5047465180..004b6e79f6 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -807,7 +807,7 @@ pres_plasma_thermal_on_axis: float = None -"""central total plasma pressure (Pa)""" +"""Plasma central thermal pressure (no fast ions or beam pressure) (Pa)""" pres_plasma_total_profile: list[float] = None """Profile of total pressure in plasma (Pa)""" @@ -828,7 +828,7 @@ """Number of elements in plasma profile""" pres_plasma_thermal_vol_avg: float = None -"""Volume averaged thermal plasma pressure (Pa)""" +"""Volume averaged thermal plasma pressure (no fast ions or beam pressure) (Pa)""" f_dd_branching_trit: float = None From d5907d3f5420e77d836ccc9e3305707debdd516d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 14:06:48 +0100 Subject: [PATCH 17/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`pcoef`=20to=20`f?= =?UTF-8?q?=5Ftemp=5Fplasma=5Felectron=5Fdensity=5Fvol=5Favg`=20for=20clar?= =?UTF-8?q?ity=20and=20consistency=20in=20plasma=20temperature=20calculati?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process/data_structure/physics_variables.py | 8 ++++---- process/io/plot_proc.py | 2 +- process/physics.py | 8 ++++---- process/plasma_profiles.py | 10 ++++++---- tests/unit/test_physics.py | 12 ++++++++---- tests/unit/test_plasma_profiles.py | 16 +++++++++++----- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 004b6e79f6..beaefa7bdf 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -887,8 +887,8 @@ """Non-alpha charged particle fusion power per volume [MW/m3]""" -pcoef: float = None -"""profile factor (= n-weighted T / average T)""" +f_temp_plasma_electron_density_vol_avg: float = None +"""Ratio of density weighted plasma electron tempertaurature to volume averaged (Profile Factor)""" p_plasma_inner_rad_mw: float = None @@ -1512,7 +1512,7 @@ def init_physics_variables(): global p_beam_dt_mw global p_non_alpha_charged_mw global pden_non_alpha_charged_mw - global pcoef + global f_temp_plasma_electron_density_vol_avg global p_plasma_inner_rad_mw global pden_plasma_core_rad_mw global p_dd_total_mw @@ -1765,7 +1765,7 @@ def init_physics_variables(): p_beam_dt_mw = 0.0 p_non_alpha_charged_mw = 0.0 pden_non_alpha_charged_mw = 0.0 - pcoef = 0.0 + f_temp_plasma_electron_density_vol_avg = 0.0 p_plasma_inner_rad_mw = 0.0 pden_plasma_core_rad_mw = 0.0 p_dd_total_mw = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index b3a37ce23b..dd1f034802 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3832,7 +3832,7 @@ def plot_t_profiles(prof, demo_ranges, mfile_data, scan): f"{te0 / te:.3f}", rf"$T_{{\text{{e,sep}}}}$: {temp_plasma_separatrix_kev:.3f} keV" r"$ \hspace{4} \frac{{{\langle T_e \rangle_n}}}{{{\langle T_e \rangle_V}}}$: " - f"{mfile_data.data['pcoef'].get_scan(scan):.3f}", + f"{mfile_data.data['f_temp_plasma_electron_density_vol_avg'].get_scan(scan):.3f}", )) props_temperature = {"boxstyle": "round", "facecolor": "wheat", "alpha": 0.5} diff --git a/process/physics.py b/process/physics.py index 4cc918f28d..5860cc7b86 100644 --- a/process/physics.py +++ b/process/physics.py @@ -3387,7 +3387,7 @@ def plasma_composition() -> None: # (used with electron and ion power balance equations only) # No consideration of pden_non_alpha_charged_mw here... - # pcoef now calculated in plasma_profiles, after the very first + # f_temp_plasma_electron_density_vol_avg now calculated in plasma_profiles, after the very first # call of plasma_composition; use old parabolic profile estimate # in this case if physics_variables.first_call == 1: @@ -3398,7 +3398,7 @@ def plasma_composition() -> None: ) physics_variables.first_call = 0 else: - pc = physics_variables.pcoef + pc = physics_variables.f_temp_plasma_electron_density_vol_avg physics_variables.f_alpha_electron = 0.88155 * np.exp( -physics_variables.temp_plasma_electron_vol_avg_kev * pc / 67.4036 @@ -4602,8 +4602,8 @@ def outplas(self): po.ovarrf( self.outfile, "Ratio of electron density weighted temp. to volume averaged temp.", - "(pcoef)", - physics_variables.pcoef, + "(f_temp_plasma_electron_density_vol_avg)", + physics_variables.f_temp_plasma_electron_density_vol_avg, "OP ", ) po.ovarre( diff --git a/process/plasma_profiles.py b/process/plasma_profiles.py index 2408da1b22..5f29363b9e 100644 --- a/process/plasma_profiles.py +++ b/process/plasma_profiles.py @@ -142,7 +142,7 @@ def parabolic_paramterisation(self) -> None: # Profile factor; ratio of density-weighted to volume-averaged # temperature - physics_variables.pcoef = ( + physics_variables.f_temp_plasma_electron_density_vol_avg = ( (1.0e0 + physics_variables.alphan) * (1.0e0 + physics_variables.alphat) / (1.0e0 + physics_variables.alphan + physics_variables.alphat) @@ -162,10 +162,12 @@ def parabolic_paramterisation(self) -> None: # Density-weighted temperatures physics_variables.temp_plasma_electron_density_weighted_kev = ( - physics_variables.temp_plasma_electron_vol_avg_kev * physics_variables.pcoef + physics_variables.temp_plasma_electron_vol_avg_kev + * physics_variables.f_temp_plasma_electron_density_vol_avg ) physics_variables.temp_plasma_ion_density_weighted_kev = ( - physics_variables.temp_plasma_ion_vol_avg_kev * physics_variables.pcoef + physics_variables.temp_plasma_ion_vol_avg_kev + * physics_variables.f_temp_plasma_electron_density_vol_avg ) # Central values for temperature (keV) and density (m**-3) @@ -234,7 +236,7 @@ def pedestal_parameterisation(self) -> None: # Profile factor; ratio of density-weighted to volume-averaged # temperature - physics_variables.pcoef = ( + physics_variables.f_temp_plasma_electron_density_vol_avg = ( physics_variables.temp_plasma_electron_density_weighted_kev / physics_variables.temp_plasma_electron_vol_avg_kev ) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index 6dd3893ed9..dd6429c45d 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1394,7 +1394,7 @@ class PlasmaCompositionParam(NamedTuple): nd_impurities: Any = None - pcoef: Any = None + f_temp_plasma_electron_density_vol_avg: Any = None fusden_alpha_total: Any = None @@ -1546,7 +1546,7 @@ class PlasmaCompositionParam(NamedTuple): f_nd_beam_electron=0, zeff=0, nd_impurities=0, - pcoef=0, + f_temp_plasma_electron_density_vol_avg=0, fusden_alpha_total=0, f_nd_plasma_iron_argon_electron=0, m_beam_amu=0, @@ -1664,7 +1664,7 @@ class PlasmaCompositionParam(NamedTuple): f_nd_beam_electron=0, zeff=2.0909945616489103, nd_impurities=28875000000000004, - pcoef=1.0521775929921553, + f_temp_plasma_electron_density_vol_avg=1.0521775929921553, fusden_alpha_total=1.973996644759543e17, f_nd_plasma_iron_argon_electron=0, m_beam_amu=2.01355414, @@ -1834,7 +1834,11 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): physics_variables, "nd_impurities", plasmacompositionparam.nd_impurities ) - monkeypatch.setattr(physics_variables, "pcoef", plasmacompositionparam.pcoef) + monkeypatch.setattr( + physics_variables, + "f_temp_plasma_electron_density_vol_avg", + plasmacompositionparam.f_temp_plasma_electron_density_vol_avg, + ) monkeypatch.setattr( physics_variables, diff --git a/tests/unit/test_plasma_profiles.py b/tests/unit/test_plasma_profiles.py index 37dbe8e27a..a926127b17 100644 --- a/tests/unit/test_plasma_profiles.py +++ b/tests/unit/test_plasma_profiles.py @@ -147,7 +147,7 @@ class PlasmaProfilesParam(NamedTuple): temp_plasma_separatrix_kev: float = 0.0 - pcoef: float = 0.0 + f_temp_plasma_electron_density_vol_avg: float = 0.0 i_plasma_pedestal: float = 0.0 @@ -228,7 +228,7 @@ class PlasmaProfilesParam(NamedTuple): pres_plasma_thermal_on_axis=0.0, nd_plasma_separatrix_electron=3.6421334486704804e19, temp_plasma_separatrix_kev=0.10000000000000001, - pcoef=0.0, + f_temp_plasma_electron_density_vol_avg=0.0, i_plasma_pedestal=1, nd_plasma_ions_on_axis=0.0, nd_plasma_electron_on_axis=0.0, @@ -273,7 +273,7 @@ class PlasmaProfilesParam(NamedTuple): pres_plasma_thermal_on_axis=868071.46874220832, nd_plasma_separatrix_electron=3.6421334486704804e19, temp_plasma_separatrix_kev=0.10000000000000001, - pcoef=1.1110842637642833, + f_temp_plasma_electron_density_vol_avg=1.1110842637642833, i_plasma_pedestal=1, nd_plasma_ions_on_axis=9.210720071916929e19, nd_plasma_electron_on_axis=1.0585658890823703e20, @@ -371,7 +371,11 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): plasmaprofilesparam.temp_plasma_separatrix_kev, ) - monkeypatch.setattr(physics_variables, "pcoef", plasmaprofilesparam.pcoef) + monkeypatch.setattr( + physics_variables, + "f_temp_plasma_electron_density_vol_avg", + plasmaprofilesparam.f_temp_plasma_electron_density_vol_avg, + ) monkeypatch.setattr( physics_variables, "i_plasma_pedestal", plasmaprofilesparam.i_plasma_pedestal @@ -486,7 +490,9 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): plasmaprofilesparam.expected_p0 ) - assert physics_variables.pcoef == pytest.approx(plasmaprofilesparam.expected_pcoef) + assert physics_variables.f_temp_plasma_electron_density_vol_avg == pytest.approx( + plasmaprofilesparam.expected_pcoef + ) assert physics_variables.nd_plasma_ions_on_axis == pytest.approx( plasmaprofilesparam.expected_ni0 From 7c8f3302c4b74947eca4dcb287331598fd22746d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:04:05 +0100 Subject: [PATCH 18/30] =?UTF-8?q?=F0=9F=94=84=20Updated=20variable=20names?= =?UTF-8?q?=20from=20`nd=5Ffuel=5Fions`=20to=20`nd=5Fplasma=5Ffuel=5Fions?= =?UTF-8?q?=5Fvol=5Favg`=20across=20multiple=20files=20to=20enhance=20clar?= =?UTF-8?q?ity=20and=20maintain=20consistency=20in=20the=20codebase.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fusion_reactions/beam_reactions.md | 4 +- .../physics-models/plasma_composition.md | 2 +- .../data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_3_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/current_drive.py | 8 ++-- process/data_structure/physics_variables.py | 8 ++-- process/fusion_reactions.py | 32 ++++++------- process/io/plot_proc.py | 14 +++--- process/physics.py | 48 +++++++++---------- process/physics_functions.py | 8 ++-- process/plasma_profiles.py | 2 +- process/stellarator.py | 10 ++-- tests/unit/test_fusion_reactions.py | 2 +- tests/unit/test_neoclassics.py | 6 +-- tests/unit/test_physics.py | 22 ++++----- 20 files changed, 90 insertions(+), 90 deletions(-) diff --git a/documentation/physics-models/fusion_reactions/beam_reactions.md b/documentation/physics-models/fusion_reactions/beam_reactions.md index 2907706a7c..7b12c755a8 100644 --- a/documentation/physics-models/fusion_reactions/beam_reactions.md +++ b/documentation/physics-models/fusion_reactions/beam_reactions.md @@ -103,8 +103,8 @@ Please see the [H&CD section](../../eng-models/heating_and_current_drive/heating 3. **Set the plasma tritium and ion densities** $$ - \mathtt{deuterium\_density = nd_fuel_ions * f\_deuterium\_plasma} \\ - \mathtt{tritium\_density = nd_fuel_ions * f\_tritium\_plasma} + \mathtt{deuterium\_density = nd_plasma_fuel_ions_vol_avg * f\_deuterium\_plasma} \\ + \mathtt{tritium\_density = nd_plasma_fuel_ions_vol_avg * f\_tritium\_plasma} $$ 4. **Calculate the beam alpha powers, density and deposited energy** diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index c920612b0f..5ce79008b2 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -116,7 +116,7 @@ All of the plasma composites are normally given as a fraction of the volume aver \mathtt{nd\_fuel\_ions} | n_{\text{i}} = \frac{\mathtt{znfuel}}{1+f_{\text{3He}}} $$ - - Calculate the fuel ion density (`nd_fuel_ions`). + - Calculate the fuel ion density (`nd_plasma_fuel_ions_vol_avg`). 7. **Set Hydrogen and Helium Impurity Fractions** diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index 78130f24e3..ee1cb39b1a 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -370,7 +370,7 @@ Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9697E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.2127E+19 OP - Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.5392E+19 OP + Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.5392E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6024E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.6709E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8502E+16 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index b848bc90df..0d1475cfba 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -371,7 +371,7 @@ Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP - Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP + Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index 176d478074..41b4b11d76 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -371,7 +371,7 @@ Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP - Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP + Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 64693f8b86..3cbfb9761c 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -371,7 +371,7 @@ Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP - Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP + Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protonstons)______________________ 1.8963E+16 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index 60e615b138..e0181d2f54 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -371,7 +371,7 @@ Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP - Fuel_density_(/m3)______________________________________________________ (nd_fuel_ions)________________________ 6.4831E+19 OP + Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 685d4b1eed..802a71cbfc 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -235,7 +235,7 @@ Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.26860509860517632e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19833068191158598e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.06084473006886912e+19 OP - Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.58453241268011663e+19 OP + Fuel_ion_number_density_(/m3)____________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)_________________ 6.58453241268011663e+19 OP Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 5.43985672856892960e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 4.69634891516571443e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 6.02387639886502110e-02 diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index be4fe44a48..2b0da0a407 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -307,7 +307,7 @@ Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.63957209157818230e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999999999999951e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.34892735750798868e+19 OP - Fuel_ion_number_density_(/m3)____________________________________________ (nd_fuel_ions)_________________ 6.49714589130413015e+19 OP + Fuel_ion_number_density_(/m3)____________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)_________________ 6.49714589130413015e+19 OP Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 6.41695061162086560e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 8.43080585227756646e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 9.91767380612879751e-02 diff --git a/process/current_drive.py b/process/current_drive.py index 62d2d126ab..3e14e1b2d0 100644 --- a/process/current_drive.py +++ b/process/current_drive.py @@ -72,10 +72,10 @@ def iternb(self): fshine = max(fshine, 1e-20) # Deuterium and tritium beam densities - dend = physics_variables.nd_fuel_ions * ( + dend = physics_variables.nd_plasma_fuel_ions_vol_avg * ( 1.0 - current_drive_variables.f_beam_tritium ) - dent = physics_variables.nd_fuel_ions * current_drive_variables.f_beam_tritium + dent = physics_variables.nd_plasma_fuel_ions_vol_avg * current_drive_variables.f_beam_tritium # Power split to ions / electrons f_p_beam_injected_ions = self.cfnbi( @@ -157,10 +157,10 @@ def culnbi(self): # Deuterium and tritium beam densities - dend = physics_variables.nd_fuel_ions * ( + dend = physics_variables.nd_plasma_fuel_ions_vol_avg * ( 1.0e0 - current_drive_variables.f_beam_tritium ) - dent = physics_variables.nd_fuel_ions * current_drive_variables.f_beam_tritium + dent = physics_variables.nd_plasma_fuel_ions_vol_avg * current_drive_variables.f_beam_tritium # Power split to ions / electrons diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index beaefa7bdf..3dcb8de461 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -330,8 +330,8 @@ """Plasma volume averaged electron density (/m3) (`iteration variable 6`)""" -nd_fuel_ions: float = None -"""fuel ion density (/m3)""" +nd_plasma_fuel_ions_vol_avg: float = None +"""Plasma volume averaged fuel ion density (/m3)""" dlamee: float = None @@ -1404,7 +1404,7 @@ def init_physics_variables(): global f_vol_plasma global f_r_conducting_wall global nd_plasma_electrons_vol_avg - global nd_fuel_ions + global nd_plasma_fuel_ions_vol_avg global dlamee global dlamie global dlimit @@ -1657,7 +1657,7 @@ def init_physics_variables(): f_vol_plasma = 1.0 f_r_conducting_wall = 1.35 nd_plasma_electrons_vol_avg = 9.8e19 - nd_fuel_ions = 0.0 + nd_plasma_fuel_ions_vol_avg = 0.0 dlamee = 0.0 dlamie = 0.0 dlimit = np.zeros(8, dtype=np.float64) diff --git a/process/fusion_reactions.py b/process/fusion_reactions.py index 3527aad907..39504764e8 100644 --- a/process/fusion_reactions.py +++ b/process/fusion_reactions.py @@ -224,7 +224,7 @@ def dt_reaction(self) -> None: * ( self.plasma_profile.neprofile.profile_y * ( - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg / physics_variables.nd_plasma_electrons_vol_avg ) ) @@ -250,9 +250,9 @@ def dt_reaction(self) -> None: * reaction_energy * ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg ) - * (physics_variables.f_plasma_fuel_tritium * physics_variables.nd_fuel_ions) + * (physics_variables.f_plasma_fuel_tritium * physics_variables.nd_plasma_fuel_ions_vol_avg) ) # Power densities for different particles [MW/m^3] @@ -327,7 +327,7 @@ def dhe3_reaction(self) -> None: * ( self.plasma_profile.neprofile.profile_y * ( - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg / physics_variables.nd_plasma_electrons_vol_avg ) ) @@ -343,9 +343,9 @@ def dhe3_reaction(self) -> None: * reaction_energy * ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg ) - * (physics_variables.f_plasma_fuel_helium3 * physics_variables.nd_fuel_ions) + * (physics_variables.f_plasma_fuel_helium3 * physics_variables.nd_plasma_fuel_ions_vol_avg) ) # Power densities for different particles [MW/m^3] @@ -421,7 +421,7 @@ def dd_helion_reaction(self) -> None: * ( self.plasma_profile.neprofile.profile_y * ( - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg / physics_variables.nd_plasma_electrons_vol_avg ) ) @@ -440,11 +440,11 @@ def dd_helion_reaction(self) -> None: * (1.0 - self.f_dd_branching_trit) * ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg ) * ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg ) ) @@ -521,7 +521,7 @@ def dd_triton_reaction(self) -> None: * ( self.plasma_profile.neprofile.profile_y * ( - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg / physics_variables.nd_plasma_electrons_vol_avg ) ) @@ -540,11 +540,11 @@ def dd_triton_reaction(self) -> None: * self.f_dd_branching_trit * ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg ) * ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg ) ) @@ -900,7 +900,7 @@ def beam_fusion( b_plasma_toroidal_on_axis: float, c_beam_total: float, nd_plasma_electrons_vol_avg: float, - nd_fuel_ions: float, + nd_plasma_fuel_ions_vol_avg: float, ion_electron_coulomb_log: float, e_beam_kev: float, f_deuterium_plasma: float, @@ -925,7 +925,7 @@ def beam_fusion( b_plasma_toroidal_on_axis (float): Toroidal field on axis (T). c_beam_total (float): Neutral beam current (A). nd_plasma_electrons_vol_avg (float): Electron density (m^-3). - nd_fuel_ions (float): Fuel ion density (m^-3). + nd_plasma_fuel_ions_vol_avg (float): Fuel ion density (m^-3). ion_electron_coulomb_log (float): Ion-electron coulomb logarithm. e_beam_kev (float): Neutral beam energy (keV). f_deuterium_plasma (float): Deuterium fraction of main plasma. @@ -990,8 +990,8 @@ def beam_fusion( ) # Deuterium and tritium ion densities - deuterium_density = nd_fuel_ions * f_deuterium_plasma - tritium_density = nd_fuel_ions * f_tritium_plasma + deuterium_density = nd_plasma_fuel_ions_vol_avg * f_deuterium_plasma + tritium_density = nd_plasma_fuel_ions_vol_avg * f_tritium_plasma ( deuterium_beam_alpha_power, diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index dd1f034802..a963b8b66e 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3588,13 +3588,13 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): + (ne0 - nd_plasma_pedestal_electron) * (1 - rhocore**2 / radius_plasma_pedestal_density_norm**2) ** alphan ) - nicore = necore * (nd_fuel_ions / nd_plasma_electrons_vol_avg) + nicore = necore * (nd_plasma_fuel_ions_vol_avg / nd_plasma_electrons_vol_avg) rhosep = np.linspace(radius_plasma_pedestal_density_norm, 1) neesep = nd_plasma_separatrix_electron + ( nd_plasma_pedestal_electron - nd_plasma_separatrix_electron ) * (1 - rhosep) / (1 - min(0.9999, radius_plasma_pedestal_density_norm)) - nisep = neesep * (nd_fuel_ions / nd_plasma_electrons_vol_avg) + nisep = neesep * (nd_plasma_fuel_ions_vol_avg / nd_plasma_electrons_vol_avg) rho = np.append(rhocore, rhosep) ne = np.append(necore, neesep) @@ -3604,7 +3604,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): rho2 = np.linspace(0.95, 1) rho = np.append(rho1, rho2) ne = ne0 * (1 - rho**2) ** alphan - ni = (ne0 * (nd_fuel_ions / nd_plasma_electrons_vol_avg)) * ( + ni = (ne0 * (nd_plasma_fuel_ions_vol_avg / nd_plasma_electrons_vol_avg)) * ( 1 - rho**2 ) ** alphan ne = ne / 1e19 @@ -3652,7 +3652,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): rf"$\hspace{{4}} \alpha_{{\text{{n}}}}$: {alphan:.3f}", rf"$n_{{\text{{e,ped}}}}$: {nd_plasma_pedestal_electron:.3e} m$^{{-3}}$" r"$ \hspace{3} \frac{\langle n_i \rangle}{\langle n_e \rangle}$: " - f"{nd_fuel_ions / nd_plasma_electrons_vol_avg:.3f}", + f"{nd_plasma_fuel_ions_vol_avg / nd_plasma_electrons_vol_avg:.3f}", rf"$f_{{\text{{GW e,ped}}}}$: {fgwped_out:.3f}" r"$ \hspace{7} \frac{n_{e,0}}{\langle n_e \rangle}$: " f"{ne0 / nd_plasma_electrons_vol_avg:.3f}", @@ -3678,7 +3678,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): r"$\langle n_{\text{ions-total}} \rangle $: " f"{mfile_data.data['nd_ions_total'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{fuel}} \rangle $: " - f"{mfile_data.data['nd_fuel_ions'].get_scan(scan):.3e} m$^{{-3}}$", + f"{mfile_data.data['nd_plasma_fuel_ions_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{alpha}} \rangle $: " f"{mfile_data.data['nd_plasma_alphas_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{impurities}} \rangle $: " @@ -11122,7 +11122,7 @@ def main(args=None): global alphan global alphat global ne0 - global nd_fuel_ions + global nd_plasma_fuel_ions_vol_avg global nd_plasma_electrons_vol_avg global te0 global ti @@ -11152,7 +11152,7 @@ def main(args=None): alphan = m_file.data["alphan"].get_scan(scan) alphat = m_file.data["alphat"].get_scan(scan) ne0 = m_file.data["nd_plasma_electron_on_axis"].get_scan(scan) - nd_fuel_ions = m_file.data["nd_fuel_ions"].get_scan(scan) + nd_plasma_fuel_ions_vol_avg = m_file.data["nd_plasma_fuel_ions_vol_avg"].get_scan(scan) nd_plasma_electrons_vol_avg = m_file.data["nd_plasma_electrons_vol_avg"].get_scan( scan ) diff --git a/process/physics.py b/process/physics.py index 5860cc7b86..7e697590ab 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1596,7 +1596,7 @@ def physics(self): physics_variables.m_fuel_amu, physics_variables.m_ions_total_amu, physics_variables.nd_ions_total, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.nd_plasma_alphas_vol_avg, physics_variables.vol_plasma, physics_variables.nd_plasma_electrons_vol_avg, @@ -2205,7 +2205,7 @@ def physics(self): physics_variables.b_plasma_toroidal_on_axis, current_drive_variables.c_beam_total, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.dlamie, current_drive_variables.e_beam_kev, physics_variables.f_plasma_fuel_deuterium, @@ -2280,7 +2280,7 @@ def physics(self): physics_variables.b_plasma_poloidal_average, physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.nd_ions_total, physics_variables.temp_plasma_electron_density_weighted_kev, physics_variables.temp_plasma_ion_density_weighted_kev, @@ -2566,7 +2566,7 @@ def physics(self): physics_variables.aspect, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.temp_plasma_electron_vol_avg_kev, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.fusden_total, physics_variables.fusden_alpha_total, physics_variables.plasma_current, @@ -3288,10 +3288,10 @@ def plasma_composition() -> None: # ====================================================================== - # Fuel ion density, nd_fuel_ions - # For D-T-He3 mix, nd_fuel_ions = nD + nT + nHe3, while znfuel = nD + nT + 2*nHe3 - # So nd_fuel_ions = znfuel - nHe3 = znfuel - f_plasma_fuel_helium3*nd_fuel_ions - physics_variables.nd_fuel_ions = znfuel / ( + # Fuel ion density, nd_plasma_fuel_ions_vol_avg + # For D-T-He3 mix, nd_plasma_fuel_ions_vol_avg = nD + nT + nHe3, while znfuel = nD + nT + 2*nHe3 + # So nd_plasma_fuel_ions_vol_avg = znfuel - nHe3 = znfuel - f_plasma_fuel_helium3*nd_plasma_fuel_ions_vol_avg + physics_variables.nd_plasma_fuel_ions_vol_avg = znfuel / ( 1.0 + physics_variables.f_plasma_fuel_helium3 ) @@ -3307,7 +3307,7 @@ def plasma_composition() -> None: physics_variables.f_plasma_fuel_deuterium + physics_variables.f_plasma_fuel_tritium ) - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg + physics_variables.nd_beam_ions ) / physics_variables.nd_plasma_electrons_vol_avg @@ -3315,7 +3315,7 @@ def plasma_composition() -> None: impurity_radiation.element2index("He") ] = ( physics_variables.f_plasma_fuel_helium3 - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg / physics_variables.nd_plasma_electrons_vol_avg + physics_variables.f_nd_alpha_electron ) @@ -3335,7 +3335,7 @@ def plasma_composition() -> None: # Total ion density physics_variables.nd_ions_total = ( - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg + physics_variables.nd_plasma_alphas_vol_avg + physics_variables.nd_plasma_protons_vol_avg + physics_variables.nd_beam_ions @@ -3426,7 +3426,7 @@ def plasma_composition() -> None: # Average mass of all ions physics_variables.m_ions_total_amu = ( - (physics_variables.m_fuel_amu * physics_variables.nd_fuel_ions) + (physics_variables.m_fuel_amu * physics_variables.nd_plasma_fuel_ions_vol_avg) + (constants.M_ALPHA_AMU * physics_variables.nd_plasma_alphas_vol_avg) + (physics_variables.nd_plasma_protons_vol_avg * constants.M_PROTON_AMU) + (physics_variables.m_beam_amu * physics_variables.nd_beam_ions) @@ -3450,18 +3450,18 @@ def plasma_composition() -> None: physics_variables.zeffai = ( ( physics_variables.f_plasma_fuel_deuterium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg / constants.M_DEUTERON_AMU ) + ( physics_variables.f_plasma_fuel_tritium - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg / constants.M_TRITON_AMU ) + ( 4.0 * physics_variables.f_plasma_fuel_helium3 - * physics_variables.nd_fuel_ions + * physics_variables.nd_plasma_fuel_ions_vol_avg / constants.M_HELION_AMU ) + (4.0 * physics_variables.nd_plasma_alphas_vol_avg / constants.M_ALPHA_AMU) @@ -3496,7 +3496,7 @@ def phyaux( aspect: float, nd_plasma_electrons_vol_avg: float, te: float, - nd_fuel_ions: float, + nd_plasma_fuel_ions_vol_avg: float, fusden_total: float, fusden_alpha_total: float, plasma_current: float, @@ -3511,7 +3511,7 @@ def phyaux( aspect (float): Plasma aspect ratio. nd_plasma_electrons_vol_avg (float): Electron density (/m3). te (float): Volume avergaed electron temperature (keV). - nd_fuel_ions (float): Fuel ion density (/m3). + nd_plasma_fuel_ions_vol_avg (float): Fuel ion density (/m3). fusden_total (float): Fusion reaction rate from plasma and beams (/m3/s). fusden_alpha_total (float): Alpha particle production rate (/m3/s). plasma_current (float): Plasma current (A). @@ -3562,7 +3562,7 @@ def phyaux( if physics_variables.burnup_in <= 1.0e-9: burnup = ( nd_plasma_alphas_vol_avg - / (nd_plasma_alphas_vol_avg + 0.5 * nd_fuel_ions) + / (nd_plasma_alphas_vol_avg + 0.5 * nd_plasma_fuel_ions_vol_avg) / physics_variables.tauratio ) else: @@ -4690,8 +4690,8 @@ def outplas(self): po.ovarre( self.outfile, "Fuel ion number density (/m3)", - "(nd_fuel_ions)", - physics_variables.nd_fuel_ions, + "(nd_plasma_fuel_ions_vol_avg)", + physics_variables.nd_plasma_fuel_ions_vol_avg, "OP ", ) po.ovarre( @@ -8508,7 +8508,7 @@ def calculate_plasma_masses( m_fuel_amu: float, m_ions_total_amu: float, nd_ions_total: float, - nd_fuel_ions: float, + nd_plasma_fuel_ions_vol_avg: float, nd_plasma_alphas_vol_avg: float, vol_plasma: float, nd_plasma_electrons_vol_avg: float, @@ -8522,8 +8522,8 @@ def calculate_plasma_masses( :type m_ions_total_amu: float :param nd_ions_total: Total ion density (/m3). :type nd_ions_total: float - :param nd_fuel_ions: Fuel ion density (/m3). - :type nd_fuel_ions: float + :param nd_plasma_fuel_ions_vol_avg: Fuel ion density (/m3). + :type nd_plasma_fuel_ions_vol_avg: float :param nd_plasma_alphas_vol_avg: Alpha ash density (/m3). :type nd_plasma_alphas_vol_avg: float :param vol_plasma: Plasma volume (m3). @@ -8537,7 +8537,7 @@ def calculate_plasma_masses( # Calculate mass of fuel ions m_plasma_fuel_ions = (m_fuel_amu * constants.ATOMIC_MASS_UNIT) * ( - nd_fuel_ions * vol_plasma + nd_plasma_fuel_ions_vol_avg * vol_plasma ) m_plasma_ions_total = (m_ions_total_amu * constants.ATOMIC_MASS_UNIT) * ( diff --git a/process/physics_functions.py b/process/physics_functions.py index 972369e034..dca2bd40ca 100644 --- a/process/physics_functions.py +++ b/process/physics_functions.py @@ -225,7 +225,7 @@ def fast_alpha_beta( b_plasma_poloidal_average: float, b_plasma_toroidal_on_axis: float, nd_plasma_electrons_vol_avg: float, - nd_fuel_ions: float, + nd_plasma_fuel_ions_vol_avg: float, nd_ions_total: float, temp_plasma_electron_density_weighted_kev: float, temp_plasma_ion_density_weighted_kev: float, @@ -242,7 +242,7 @@ def fast_alpha_beta( b_plasma_poloidal_average (float): Poloidal field (T). b_plasma_toroidal_on_axis (float): Toroidal field on axis (T). nd_plasma_electrons_vol_avg (float): Electron density (m^-3). - nd_fuel_ions (float): Fuel ion density (m^-3). + nd_plasma_fuel_ions_vol_avg (float): Fuel ion density (m^-3). nd_ions_total (float): Total ion density (m^-3). temp_plasma_electron_density_weighted_kev (float): Density-weighted electron temperature (keV). temp_plasma_ion_density_weighted_kev (float): Density-weighted ion temperature (keV). @@ -286,7 +286,7 @@ def fast_alpha_beta( fact = min( 0.3, 0.29 - * (nd_fuel_ions / nd_plasma_electrons_vol_avg) ** 2 + * (nd_plasma_fuel_ions_vol_avg / nd_plasma_electrons_vol_avg) ** 2 * ( ( temp_plasma_electron_density_weighted_kev @@ -302,7 +302,7 @@ def fast_alpha_beta( fact = min( 0.30, 0.26 - * (nd_fuel_ions / nd_plasma_electrons_vol_avg) ** 2 + * (nd_plasma_fuel_ions_vol_avg / nd_plasma_electrons_vol_avg) ** 2 * np.sqrt( max( 0.0, diff --git a/process/plasma_profiles.py b/process/plasma_profiles.py index 5f29363b9e..9fabe9a5e0 100644 --- a/process/plasma_profiles.py +++ b/process/plasma_profiles.py @@ -305,7 +305,7 @@ def calculate_profile_factors(self) -> None: # Fuel ion pressure profile (Pa) physics_variables.pres_plasma_fuel_profile = ( - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg * (self.neprofile.profile_y / physics_variables.nd_plasma_electrons_vol_avg) ) * ( self.teprofile.profile_y diff --git a/process/stellarator.py b/process/stellarator.py index a38db6115c..f18bd9a72e 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4347,7 +4347,7 @@ def stphys(self, output): physics_variables.b_plasma_toroidal_on_axis, current_drive_variables.c_beam_total, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.dlamie, current_drive_variables.e_beam_kev, physics_variables.f_plasma_fuel_deuterium, @@ -4410,7 +4410,7 @@ def stphys(self, output): physics_variables.b_plasma_poloidal_average, physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.nd_ions_total, physics_variables.temp_plasma_electron_density_weighted_kev, physics_variables.temp_plasma_ion_density_weighted_kev, @@ -4658,7 +4658,7 @@ def stphys(self, output): physics_variables.aspect, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.temp_plasma_electron_vol_avg_kev, - physics_variables.nd_fuel_ions, + physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.fusden_total, physics_variables.fusden_alpha_total, physics_variables.plasma_current, @@ -5630,8 +5630,8 @@ def neoclassics_calc_nu_star_fromT(self, iota): ) density = np.array([ physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_fuel_ions * physics_variables.f_plasma_fuel_deuterium, - physics_variables.nd_fuel_ions + physics_variables.nd_plasma_fuel_ions_vol_avg * physics_variables.f_plasma_fuel_deuterium, + physics_variables.nd_plasma_fuel_ions_vol_avg * (1 - physics_variables.f_plasma_fuel_deuterium), physics_variables.nd_plasma_alphas_vol_avg, ]) diff --git a/tests/unit/test_fusion_reactions.py b/tests/unit/test_fusion_reactions.py index aa4ba37d55..044f431a8f 100644 --- a/tests/unit/test_fusion_reactions.py +++ b/tests/unit/test_fusion_reactions.py @@ -23,7 +23,7 @@ class SetFusionPowersParam(NamedTuple): nd_plasma_electrons_vol_avg: Any = None - nd_fuel_ions: Any = None + nd_plasma_fuel_ions_vol_avg: Any = None nd_ions_total: Any = None diff --git a/tests/unit/test_neoclassics.py b/tests/unit/test_neoclassics.py index 86af0afc77..8c8ad33b2a 100644 --- a/tests/unit/test_neoclassics.py +++ b/tests/unit/test_neoclassics.py @@ -32,7 +32,7 @@ class InitNeoclassicsParam(NamedTuple): te: Any = None ti: Any = None nd_plasma_electrons_vol_avg: Any = None - nd_fuel_ions: Any = None + nd_plasma_fuel_ions_vol_avg: Any = None densities: Any = None temperatures: Any = None dr_densities: Any = None @@ -81,7 +81,7 @@ class InitNeoclassicsParam(NamedTuple): te=6.0190000000000001, ti=5.7180500000000007, nd_plasma_electrons_vol_avg=2.07086e20, - nd_fuel_ions=1.47415411616e20, + nd_plasma_fuel_ions_vol_avg=1.47415411616e20, densities=np.array( np.array((0, 0, 0, 0), order="F"), order="F" ).transpose(), @@ -1024,7 +1024,7 @@ def test_init_neoclassics(initneoclassicsparam, monkeypatch, neoclassics): initneoclassicsparam.nd_plasma_electrons_vol_avg, ) monkeypatch.setattr( - physics_variables, "nd_fuel_ions", initneoclassicsparam.nd_fuel_ions + physics_variables, "nd_plasma_fuel_ions_vol_avg", initneoclassicsparam.nd_plasma_fuel_ions_vol_avg ) monkeypatch.setattr( neoclassics_variables, "densities", initneoclassicsparam.densities diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index dd6429c45d..20367767ea 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1368,7 +1368,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_tritium: Any = None - nd_fuel_ions: Any = None + nd_plasma_fuel_ions_vol_avg: Any = None m_ions_total_amu: Any = None @@ -1533,7 +1533,7 @@ class PlasmaCompositionParam(NamedTuple): f_alpha_electron=0, m_fuel_amu=0, f_plasma_fuel_tritium=0.5, - nd_fuel_ions=0, + nd_plasma_fuel_ions_vol_avg=0, m_ions_total_amu=0, nd_ions_total=0, f_nd_protium_electrons=0, @@ -1651,7 +1651,7 @@ class PlasmaCompositionParam(NamedTuple): f_alpha_electron=0.6845930883190634, m_fuel_amu=2.5, f_plasma_fuel_tritium=0.5, - nd_fuel_ions=5.8589175702454272e19, + nd_plasma_fuel_ions_vol_avg=5.8589175702454272e19, m_ions_total_amu=2.7395439636787726, nd_ions_total=6.6125550702454276e19, f_nd_protium_electrons=0, @@ -1779,7 +1779,7 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "nd_fuel_ions", plasmacompositionparam.nd_fuel_ions + physics_variables, "nd_plasma_fuel_ions_vol_avg", plasmacompositionparam.nd_plasma_fuel_ions_vol_avg ) monkeypatch.setattr( @@ -1944,7 +1944,7 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): plasmacompositionparam.expected_m_fuel_amu ) - assert physics_variables.nd_fuel_ions == pytest.approx( + assert physics_variables.nd_plasma_fuel_ions_vol_avg == pytest.approx( plasmacompositionparam.expected_nd_fuel_ions ) @@ -2149,7 +2149,7 @@ class PhyauxParam(NamedTuple): te: Any = None - nd_fuel_ions: Any = None + nd_plasma_fuel_ions_vol_avg: Any = None nd_plasma_alphas_vol_avg: Any = None @@ -2191,7 +2191,7 @@ class PhyauxParam(NamedTuple): aspect=3, nd_plasma_electrons_vol_avg=7.5e19, te=12.569, - nd_fuel_ions=5.8589175702454272e19, + nd_plasma_fuel_ions_vol_avg=5.8589175702454272e19, nd_plasma_alphas_vol_avg=7.5e18, fusden_total=1.9852091609123786e17, fusden_alpha_total=1.973996644759543e17, @@ -2214,7 +2214,7 @@ class PhyauxParam(NamedTuple): aspect=3, nd_plasma_electrons_vol_avg=7.5e19, te=12.569, - nd_fuel_ions=5.8576156204039725e19, + nd_plasma_fuel_ions_vol_avg=5.8576156204039725e19, nd_plasma_alphas_vol_avg=7.5e18, fusden_total=1.9843269653375773e17, fusden_alpha_total=1.9731194318497056e17, @@ -2264,7 +2264,7 @@ def test_phyaux(phyauxparam, monkeypatch, physics): aspect=phyauxparam.aspect, nd_plasma_electrons_vol_avg=phyauxparam.nd_plasma_electrons_vol_avg, te=phyauxparam.te, - nd_fuel_ions=phyauxparam.nd_fuel_ions, + nd_plasma_fuel_ions_vol_avg=phyauxparam.nd_plasma_fuel_ions_vol_avg, nd_plasma_alphas_vol_avg=phyauxparam.nd_plasma_alphas_vol_avg, fusden_total=phyauxparam.fusden_total, fusden_alpha_total=phyauxparam.fusden_alpha_total, @@ -3354,7 +3354,7 @@ def test_calculate_plasma_masses(): m_fuel_amu = 2.5 m_ions_total_amu = 3.0 nd_ions_total = 1.0e20 - nd_fuel_ions = 0.8e20 + nd_plasma_fuel_ions_vol_avg = 0.8e20 nd_plasma_alphas_vol_avg = 0.1e20 vol_plasma = 100.0 nd_plasma_electrons_vol_avg = 1.0e20 @@ -3369,7 +3369,7 @@ def test_calculate_plasma_masses(): m_fuel_amu=m_fuel_amu, m_ions_total_amu=m_ions_total_amu, nd_ions_total=nd_ions_total, - nd_fuel_ions=nd_fuel_ions, + nd_plasma_fuel_ions_vol_avg=nd_plasma_fuel_ions_vol_avg, nd_plasma_alphas_vol_avg=nd_plasma_alphas_vol_avg, vol_plasma=vol_plasma, nd_plasma_electrons_vol_avg=nd_plasma_electrons_vol_avg, From 32eda1ed7d2d587f2cb5339d2cb66e1dcf940bbc Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:10:32 +0100 Subject: [PATCH 19/30] =?UTF-8?q?=F0=9F=94=84=20Updated=20variable=20names?= =?UTF-8?q?=20from=20`nd=5Fions=5Ftotal`=20to=20`nd=5Fplasma=5Fions=5Ftota?= =?UTF-8?q?l=5Fvol=5Favg`=20across=20multiple=20files,=20including=20data?= =?UTF-8?q?=20files,=20physics=20calculations,=20and=20tests.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../physics-models/plasma_composition.md | 2 +- .../profiles/plasma_density_profile.md | 2 +- .../profiles/plasma_profiles.md | 2 +- .../data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_3_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/constraints.py | 2 +- process/current_drive.py | 10 ++- process/data_structure/physics_variables.py | 8 +-- process/fusion_reactions.py | 10 ++- process/io/plot_proc.py | 6 +- process/physics.py | 42 ++++++------ process/physics_functions.py | 6 +- process/plasma_profiles.py | 7 +- process/profiles.py | 2 +- process/stellarator.py | 9 +-- tests/unit/test_fusion_reactions.py | 2 +- tests/unit/test_neoclassics.py | 4 +- tests/unit/test_physics.py | 64 ++++++++++--------- tests/unit/test_plasma_profiles.py | 10 +-- tracking/tracking_data.py | 2 +- 25 files changed, 117 insertions(+), 87 deletions(-) diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index 5ce79008b2..75b23fd389 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -140,7 +140,7 @@ All of the plasma composites are normally given as a fraction of the volume aver 9. **Total Ion Density Calculation** - - Calculate the total ion density (`nd_ions_total`). + - Calculate the total ion density (`nd_plasma_ions_total_vol_avg`). $$ \mathtt{nd\_ions\_total} | n_{\text{i,total}} = n_{\text{i}} + n_{\alpha}+n_{\text{protons}}+ n_{\text{beam}}+n_{\text{impurities}} diff --git a/documentation/physics-models/profiles/plasma_density_profile.md b/documentation/physics-models/profiles/plasma_density_profile.md index 867de97cf2..2193f7f8a1 100644 --- a/documentation/physics-models/profiles/plasma_density_profile.md +++ b/documentation/physics-models/profiles/plasma_density_profile.md @@ -13,7 +13,7 @@ The density profile class is organised around a central runner function that is ### Calculate core values | `set_physics_variables()` The core electron density is calculated using the [`ncore`](plasma_density_profile.md#electron-core-density-of-a-pedestalised-profile--ncore) method. -The core ion density is then set from $n_{\text{i}}$ (`nd_ions_total`) which is the total ion density such as: +The core ion density is then set from $n_{\text{i}}$ (`nd_plasma_ions_total_vol_avg`) which is the total ion density such as: $$ n_{\text{i0}} = \left(\frac{n_\text{i}}{n_\text{e}}\right)n_{\text{e0}} diff --git a/documentation/physics-models/profiles/plasma_profiles.md b/documentation/physics-models/profiles/plasma_profiles.md index 136d1927a8..107661c97f 100644 --- a/documentation/physics-models/profiles/plasma_profiles.md +++ b/documentation/physics-models/profiles/plasma_profiles.md @@ -385,7 +385,7 @@ $$\begin{aligned} $$\begin{aligned} \texttt{nd_plasma_electron_on_axis} = n_{\text{e}} \times (\alpha_n+1) \\ -\texttt{nd_plasma_ions_on_axis} = \texttt{nd_ions_total} \times (\alpha_n+1) +\texttt{nd_plasma_ions_on_axis} = \texttt{nd_plasma_ions_total_vol_avg} \times (\alpha_n+1) \end{aligned}$$ ----- diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index ee1cb39b1a..6e8201aeb7 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -369,7 +369,7 @@ Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0654E+20 OP Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9697E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP - Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.2127E+19 OP + Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.2127E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.5392E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6024E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.6709E+18 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index 0d1475cfba..f3cb861c64 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -370,7 +370,7 @@ Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP - Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP + Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index 41b4b11d76..7afc204cb2 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -370,7 +370,7 @@ Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP - Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP + Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 3cbfb9761c..4d58d6ee40 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -370,7 +370,7 @@ Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP - Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP + Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index e0181d2f54..60ea0c9c2b 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -370,7 +370,7 @@ Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP - Ion_density_(/m3)_______________________________________________________ (nd_ions_total)______________________ 7.1669E+19 OP + Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 802a71cbfc..de6654c22a 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -234,7 +234,7 @@ Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_thermal_on_axis)___________________________ 7.82668759018785902e+05 OP Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.26860509860517632e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19833068191158598e+00 OP - Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.06084473006886912e+19 OP + Total_Ion_number_density_(/m3)___________________________________________ (nd_plasma_ions_total_vol_avg)________________ 7.06084473006886912e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)_________________ 6.58453241268011663e+19 OP Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 5.43985672856892960e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 4.69634891516571443e+18 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 2b0da0a407..8f726363c4 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -306,7 +306,7 @@ Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_thermal_on_axis)___________________________ 9.10652371594472905e+05 OP Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.63957209157818230e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999999999999951e+00 OP - Total_Ion_number_density_(/m3)___________________________________________ (nd_ions_total)________________ 7.34892735750798868e+19 OP + Total_Ion_number_density_(/m3)___________________________________________ (nd_plasma_ions_total_vol_avg)________________ 7.34892735750798868e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)_________________ 6.49714589130413015e+19 OP Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 6.41695061162086560e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 8.43080585227756646e+18 OP diff --git a/process/constraints.py b/process/constraints.py index e9b1048635..66982aeb51 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -149,7 +149,7 @@ def constraint_equation_1(): * ( data_structure.physics_variables.nd_plasma_electrons_vol_avg * data_structure.physics_variables.temp_plasma_electron_density_weighted_kev - + data_structure.physics_variables.nd_ions_total + + data_structure.physics_variables.nd_plasma_ions_total_vol_avg * data_structure.physics_variables.temp_plasma_ion_density_weighted_kev ) / data_structure.physics_variables.b_plasma_total**2 diff --git a/process/current_drive.py b/process/current_drive.py index 3e14e1b2d0..92e0e4d140 100644 --- a/process/current_drive.py +++ b/process/current_drive.py @@ -75,7 +75,10 @@ def iternb(self): dend = physics_variables.nd_plasma_fuel_ions_vol_avg * ( 1.0 - current_drive_variables.f_beam_tritium ) - dent = physics_variables.nd_plasma_fuel_ions_vol_avg * current_drive_variables.f_beam_tritium + dent = ( + physics_variables.nd_plasma_fuel_ions_vol_avg + * current_drive_variables.f_beam_tritium + ) # Power split to ions / electrons f_p_beam_injected_ions = self.cfnbi( @@ -160,7 +163,10 @@ def culnbi(self): dend = physics_variables.nd_plasma_fuel_ions_vol_avg * ( 1.0e0 - current_drive_variables.f_beam_tritium ) - dent = physics_variables.nd_plasma_fuel_ions_vol_avg * current_drive_variables.f_beam_tritium + dent = ( + physics_variables.nd_plasma_fuel_ions_vol_avg + * current_drive_variables.f_beam_tritium + ) # Power split to ions / electrons diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 3dcb8de461..bf08c718c3 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -386,8 +386,8 @@ """density limit (/m3)""" -nd_ions_total: float = None -"""total ion density (/m3)""" +nd_plasma_ions_total_vol_avg: float = None +"""Plasma volume averaged total ion density (/m3)""" nd_electron_line: float = None @@ -1418,7 +1418,7 @@ def init_physics_variables(): global beta_norm_max_tholerus global beta_norm_max_stambaugh global dnelimt - global nd_ions_total + global nd_plasma_ions_total_vol_avg global nd_electron_line global nd_plasma_protons_vol_avg global ntau @@ -1671,7 +1671,7 @@ def init_physics_variables(): beta_norm_max_tholerus = 0.0 beta_norm_max_stambaugh = 0.0 dnelimt = 0.0 - nd_ions_total = 0.0 + nd_plasma_ions_total_vol_avg = 0.0 nd_electron_line = 0.0 nd_plasma_protons_vol_avg = 0.0 ntau = 0.0 diff --git a/process/fusion_reactions.py b/process/fusion_reactions.py index 39504764e8..83e378ad49 100644 --- a/process/fusion_reactions.py +++ b/process/fusion_reactions.py @@ -252,7 +252,10 @@ def dt_reaction(self) -> None: physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_plasma_fuel_ions_vol_avg ) - * (physics_variables.f_plasma_fuel_tritium * physics_variables.nd_plasma_fuel_ions_vol_avg) + * ( + physics_variables.f_plasma_fuel_tritium + * physics_variables.nd_plasma_fuel_ions_vol_avg + ) ) # Power densities for different particles [MW/m^3] @@ -345,7 +348,10 @@ def dhe3_reaction(self) -> None: physics_variables.f_plasma_fuel_deuterium * physics_variables.nd_plasma_fuel_ions_vol_avg ) - * (physics_variables.f_plasma_fuel_helium3 * physics_variables.nd_plasma_fuel_ions_vol_avg) + * ( + physics_variables.f_plasma_fuel_helium3 + * physics_variables.nd_plasma_fuel_ions_vol_avg + ) ) # Power densities for different particles [MW/m^3] diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index a963b8b66e..fc4bc3d652 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3676,7 +3676,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): textstr_ions = "\n".join(( r"$\langle n_{\text{ions-total}} \rangle $: " - f"{mfile_data.data['nd_ions_total'].get_scan(scan):.3e} m$^{{-3}}$", + f"{mfile_data.data['nd_plasma_ions_total_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{fuel}} \rangle $: " f"{mfile_data.data['nd_plasma_fuel_ions_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{alpha}} \rangle $: " @@ -11152,7 +11152,9 @@ def main(args=None): alphan = m_file.data["alphan"].get_scan(scan) alphat = m_file.data["alphat"].get_scan(scan) ne0 = m_file.data["nd_plasma_electron_on_axis"].get_scan(scan) - nd_plasma_fuel_ions_vol_avg = m_file.data["nd_plasma_fuel_ions_vol_avg"].get_scan(scan) + nd_plasma_fuel_ions_vol_avg = m_file.data["nd_plasma_fuel_ions_vol_avg"].get_scan( + scan + ) nd_plasma_electrons_vol_avg = m_file.data["nd_plasma_electrons_vol_avg"].get_scan( scan ) diff --git a/process/physics.py b/process/physics.py index 7e697590ab..ce142a0627 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1595,7 +1595,7 @@ def physics(self): ) = self.calculate_plasma_masses( physics_variables.m_fuel_amu, physics_variables.m_ions_total_amu, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_fuel_ions_vol_avg, physics_variables.nd_plasma_alphas_vol_avg, physics_variables.vol_plasma, @@ -2281,7 +2281,7 @@ def physics(self): physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_plasma_fuel_ions_vol_avg, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.temp_plasma_electron_density_weighted_kev, physics_variables.temp_plasma_ion_density_weighted_kev, physics_variables.pden_alpha_total_mw, @@ -2490,7 +2490,7 @@ def physics(self): physics_variables.p_alpha_total_mw, physics_variables.aspect, physics_variables.b_plasma_toroidal_on_axis, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_electron_line, physics_variables.eps, @@ -3334,7 +3334,7 @@ def plasma_composition() -> None: # ====================================================================== # Total ion density - physics_variables.nd_ions_total = ( + physics_variables.nd_plasma_ions_total_vol_avg = ( physics_variables.nd_plasma_fuel_ions_vol_avg + physics_variables.nd_plasma_alphas_vol_avg + physics_variables.nd_plasma_protons_vol_avg @@ -3426,7 +3426,10 @@ def plasma_composition() -> None: # Average mass of all ions physics_variables.m_ions_total_amu = ( - (physics_variables.m_fuel_amu * physics_variables.nd_plasma_fuel_ions_vol_avg) + ( + physics_variables.m_fuel_amu + * physics_variables.nd_plasma_fuel_ions_vol_avg + ) + (constants.M_ALPHA_AMU * physics_variables.nd_plasma_alphas_vol_avg) + (physics_variables.nd_plasma_protons_vol_avg * constants.M_PROTON_AMU) + (physics_variables.m_beam_amu * physics_variables.nd_beam_ions) @@ -3440,7 +3443,8 @@ def plasma_composition() -> None: ) physics_variables.m_ions_total_amu = ( - physics_variables.m_ions_total_amu / physics_variables.nd_ions_total + physics_variables.m_ions_total_amu + / physics_variables.nd_plasma_ions_total_vol_avg ) # ====================================================================== @@ -4683,8 +4687,8 @@ def outplas(self): po.ovarre( self.outfile, "Total Ion number density (/m3)", - "(nd_ions_total)", - physics_variables.nd_ions_total, + "(nd_plasma_ions_total_vol_avg)", + physics_variables.nd_plasma_ions_total_vol_avg, "OP ", ) po.ovarre( @@ -6632,7 +6636,7 @@ def output_confinement_comparison(self, istell: int) -> None: physics_variables.p_alpha_total_mw, physics_variables.aspect, physics_variables.b_plasma_toroidal_on_axis, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_electron_line, physics_variables.eps, @@ -6953,7 +6957,7 @@ def bootstrap_fraction_sauter(plasma_profile: float) -> float: # Calculate electron and ion density profiles ne = plasma_profile.neprofile.profile_y * 1e-19 ni = ( - physics_variables.nd_ions_total + physics_variables.nd_plasma_ions_total_vol_avg / physics_variables.nd_plasma_electrons_vol_avg ) * ne @@ -7562,7 +7566,7 @@ def fhz(hfact: float) -> float: physics_variables.p_alpha_total_mw, physics_variables.aspect, physics_variables.b_plasma_toroidal_on_axis, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_electron_line, physics_variables.eps, @@ -7618,7 +7622,7 @@ def calculate_confinement_time( p_alpha_total_mw: float, aspect: float, b_plasma_toroidal_on_axis: float, - nd_ions_total: float, + nd_plasma_ions_total_vol_avg: float, nd_plasma_electrons_vol_avg: float, nd_electron_line: float, eps: float, @@ -7647,7 +7651,7 @@ def calculate_confinement_time( :param p_alpha_total_mw: Alpha particle power (MW) :param aspect: Aspect ratio :param b_plasma_toroidal_on_axis: Toroidal field on axis (T) - :param nd_ions_total: Total ion density (/m3) + :param nd_plasma_ions_total_vol_avg: Total ion density (/m3) :param nd_plasma_electrons_vol_avg: Volume averaged electron density (/m3) :param nd_electron_line: Line-averaged electron density (/m3) :param eps: Inverse aspect ratio @@ -8465,7 +8469,7 @@ def calculate_confinement_time( pden_ion_transport_loss_mw = ( (3 / 2) * (constants.ELECTRON_CHARGE / 1e3) - * nd_ions_total + * nd_plasma_ions_total_vol_avg * temp_plasma_ion_density_weighted_kev / t_ion_energy_confinement ) @@ -8477,7 +8481,7 @@ def calculate_confinement_time( / t_electron_energy_confinement ) - ratio = (nd_ions_total / nd_plasma_electrons_vol_avg) * ( + ratio = (nd_plasma_ions_total_vol_avg / nd_plasma_electrons_vol_avg) * ( temp_plasma_ion_density_weighted_kev / temp_plasma_electron_density_weighted_kev ) @@ -8507,7 +8511,7 @@ def calculate_confinement_time( def calculate_plasma_masses( m_fuel_amu: float, m_ions_total_amu: float, - nd_ions_total: float, + nd_plasma_ions_total_vol_avg: float, nd_plasma_fuel_ions_vol_avg: float, nd_plasma_alphas_vol_avg: float, vol_plasma: float, @@ -8520,8 +8524,8 @@ def calculate_plasma_masses( :type m_fuel_amu: float :param m_ions_total_amu: Average mass of all ions (amu). :type m_ions_total_amu: float - :param nd_ions_total: Total ion density (/m3). - :type nd_ions_total: float + :param nd_plasma_ions_total_vol_avg: Total ion density (/m3). + :type nd_plasma_ions_total_vol_avg: float :param nd_plasma_fuel_ions_vol_avg: Fuel ion density (/m3). :type nd_plasma_fuel_ions_vol_avg: float :param nd_plasma_alphas_vol_avg: Alpha ash density (/m3). @@ -8541,7 +8545,7 @@ def calculate_plasma_masses( ) m_plasma_ions_total = (m_ions_total_amu * constants.ATOMIC_MASS_UNIT) * ( - nd_ions_total * vol_plasma + nd_plasma_ions_total_vol_avg * vol_plasma ) m_plasma_alpha = (nd_plasma_alphas_vol_avg * vol_plasma) * constants.ALPHA_MASS diff --git a/process/physics_functions.py b/process/physics_functions.py index dca2bd40ca..f0346fc5a9 100644 --- a/process/physics_functions.py +++ b/process/physics_functions.py @@ -226,7 +226,7 @@ def fast_alpha_beta( b_plasma_toroidal_on_axis: float, nd_plasma_electrons_vol_avg: float, nd_plasma_fuel_ions_vol_avg: float, - nd_ions_total: float, + nd_plasma_ions_total_vol_avg: float, temp_plasma_electron_density_weighted_kev: float, temp_plasma_ion_density_weighted_kev: float, pden_alpha_total_mw: float, @@ -243,7 +243,7 @@ def fast_alpha_beta( b_plasma_toroidal_on_axis (float): Toroidal field on axis (T). nd_plasma_electrons_vol_avg (float): Electron density (m^-3). nd_plasma_fuel_ions_vol_avg (float): Fuel ion density (m^-3). - nd_ions_total (float): Total ion density (m^-3). + nd_plasma_ions_total_vol_avg (float): Total ion density (m^-3). temp_plasma_electron_density_weighted_kev (float): Density-weighted electron temperature (keV). temp_plasma_ion_density_weighted_kev (float): Density-weighted ion temperature (keV). pden_alpha_total_mw (float): Alpha power per unit volume, from beams and plasma (MW/m^3). @@ -275,7 +275,7 @@ def fast_alpha_beta( * constants.KILOELECTRON_VOLT * ( nd_plasma_electrons_vol_avg * temp_plasma_electron_density_weighted_kev - + nd_ions_total * temp_plasma_ion_density_weighted_kev + + nd_plasma_ions_total_vol_avg * temp_plasma_ion_density_weighted_kev ) / (b_plasma_toroidal_on_axis**2 + b_plasma_poloidal_average**2) ) diff --git a/process/plasma_profiles.py b/process/plasma_profiles.py index 9fabe9a5e0..a203fd09cf 100644 --- a/process/plasma_profiles.py +++ b/process/plasma_profiles.py @@ -185,8 +185,9 @@ def parabolic_paramterisation(self) -> None: physics_variables.nd_plasma_electrons_vol_avg * (1.0 + physics_variables.alphan) ) - physics_variables.nd_plasma_ions_on_axis = physics_variables.nd_ions_total * ( - 1.0 + physics_variables.alphan + physics_variables.nd_plasma_ions_on_axis = ( + physics_variables.nd_plasma_ions_total_vol_avg + * (1.0 + physics_variables.alphan) ) def pedestal_parameterisation(self) -> None: @@ -289,7 +290,7 @@ def calculate_profile_factors(self) -> None: # Total ion pressure profile (Pa) physics_variables.pres_plasma_ion_total_profile = ( - physics_variables.nd_ions_total + physics_variables.nd_plasma_ions_total_vol_avg * (self.neprofile.profile_y / physics_variables.nd_plasma_electrons_vol_avg) ) * ( self.teprofile.profile_y diff --git a/process/profiles.py b/process/profiles.py index b228b1c6c2..118a9b987b 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -247,7 +247,7 @@ def set_physics_variables(self) -> None: physics_variables.alphan, ) physics_variables.nd_plasma_ions_on_axis = ( - physics_variables.nd_ions_total + physics_variables.nd_plasma_ions_total_vol_avg / physics_variables.nd_plasma_electrons_vol_avg * physics_variables.nd_plasma_electron_on_axis ) diff --git a/process/stellarator.py b/process/stellarator.py index f18bd9a72e..d3198982bc 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4265,7 +4265,7 @@ def stphys(self, output): * ( physics_variables.nd_plasma_electrons_vol_avg * physics_variables.temp_plasma_electron_density_weighted_kev - + physics_variables.nd_ions_total + + physics_variables.nd_plasma_ions_total_vol_avg * physics_variables.temp_plasma_ion_density_weighted_kev ) / physics_variables.b_plasma_total**2 @@ -4411,7 +4411,7 @@ def stphys(self, output): physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_plasma_fuel_ions_vol_avg, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.temp_plasma_electron_density_weighted_kev, physics_variables.temp_plasma_ion_density_weighted_kev, physics_variables.pden_alpha_total_mw, @@ -4604,7 +4604,7 @@ def stphys(self, output): physics_variables.p_alpha_total_mw, physics_variables.aspect, physics_variables.b_plasma_toroidal_on_axis, - physics_variables.nd_ions_total, + physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, physics_variables.nd_electron_line, physics_variables.eps, @@ -5630,7 +5630,8 @@ def neoclassics_calc_nu_star_fromT(self, iota): ) density = np.array([ physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_plasma_fuel_ions_vol_avg * physics_variables.f_plasma_fuel_deuterium, + physics_variables.nd_plasma_fuel_ions_vol_avg + * physics_variables.f_plasma_fuel_deuterium, physics_variables.nd_plasma_fuel_ions_vol_avg * (1 - physics_variables.f_plasma_fuel_deuterium), physics_variables.nd_plasma_alphas_vol_avg, diff --git a/tests/unit/test_fusion_reactions.py b/tests/unit/test_fusion_reactions.py index 044f431a8f..4af562eca0 100644 --- a/tests/unit/test_fusion_reactions.py +++ b/tests/unit/test_fusion_reactions.py @@ -25,7 +25,7 @@ class SetFusionPowersParam(NamedTuple): nd_plasma_fuel_ions_vol_avg: Any = None - nd_ions_total: Any = None + nd_plasma_ions_total_vol_avg: Any = None f_alpha_electron: Any = None diff --git a/tests/unit/test_neoclassics.py b/tests/unit/test_neoclassics.py index 8c8ad33b2a..0ba50e60f3 100644 --- a/tests/unit/test_neoclassics.py +++ b/tests/unit/test_neoclassics.py @@ -1024,7 +1024,9 @@ def test_init_neoclassics(initneoclassicsparam, monkeypatch, neoclassics): initneoclassicsparam.nd_plasma_electrons_vol_avg, ) monkeypatch.setattr( - physics_variables, "nd_plasma_fuel_ions_vol_avg", initneoclassicsparam.nd_plasma_fuel_ions_vol_avg + physics_variables, + "nd_plasma_fuel_ions_vol_avg", + initneoclassicsparam.nd_plasma_fuel_ions_vol_avg, ) monkeypatch.setattr( neoclassics_variables, "densities", initneoclassicsparam.densities diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index 20367767ea..b059de0107 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -329,7 +329,7 @@ def test_bootstrap_fraction_wilson(bootstrapfractionwilsonparam, physics): class BootstrapFractionSauterParam(NamedTuple): - nd_ions_total: Any = None + nd_plasma_ions_total_vol_avg: Any = None rminor: Any = None @@ -388,7 +388,7 @@ class BootstrapFractionSauterParam(NamedTuple): "bootstrapfractionsauterparam", ( BootstrapFractionSauterParam( - nd_ions_total=7.1297522422781575e19, + nd_plasma_ions_total_vol_avg=7.1297522422781575e19, rminor=2.6666666666666665, temp_plasma_separatrix_kev=0.10000000000000001, temp_plasma_ion_vol_avg_kev=12.570861186498382, @@ -432,7 +432,9 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph """ monkeypatch.setattr( - physics_variables, "nd_ions_total", bootstrapfractionsauterparam.nd_ions_total + physics_variables, + "nd_plasma_ions_total_vol_avg", + bootstrapfractionsauterparam.nd_plasma_ions_total_vol_avg, ) monkeypatch.setattr( @@ -1372,7 +1374,7 @@ class PlasmaCompositionParam(NamedTuple): m_ions_total_amu: Any = None - nd_ions_total: Any = None + nd_plasma_ions_total_vol_avg: Any = None f_nd_protium_electrons: Any = None @@ -1535,7 +1537,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_tritium=0.5, nd_plasma_fuel_ions_vol_avg=0, m_ions_total_amu=0, - nd_ions_total=0, + nd_plasma_ions_total_vol_avg=0, f_nd_protium_electrons=0, zeffai=0, f_nd_plasma_carbon_electron=0, @@ -1653,7 +1655,7 @@ class PlasmaCompositionParam(NamedTuple): f_plasma_fuel_tritium=0.5, nd_plasma_fuel_ions_vol_avg=5.8589175702454272e19, m_ions_total_amu=2.7395439636787726, - nd_ions_total=6.6125550702454276e19, + nd_plasma_ions_total_vol_avg=6.6125550702454276e19, f_nd_protium_electrons=0, zeffai=0.43046641789338563, f_nd_plasma_carbon_electron=0, @@ -1779,7 +1781,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "nd_plasma_fuel_ions_vol_avg", plasmacompositionparam.nd_plasma_fuel_ions_vol_avg + physics_variables, + "nd_plasma_fuel_ions_vol_avg", + plasmacompositionparam.nd_plasma_fuel_ions_vol_avg, ) monkeypatch.setattr( @@ -1787,7 +1791,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): ) monkeypatch.setattr( - physics_variables, "nd_ions_total", plasmacompositionparam.nd_ions_total + physics_variables, + "nd_plasma_ions_total_vol_avg", + plasmacompositionparam.nd_plasma_ions_total_vol_avg, ) monkeypatch.setattr( @@ -1952,7 +1958,7 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): plasmacompositionparam.expected_m_ions_total_amu ) - assert physics_variables.nd_ions_total == pytest.approx( + assert physics_variables.nd_plasma_ions_total_vol_avg == pytest.approx( plasmacompositionparam.expected_nd_ions_total ) @@ -2516,7 +2522,7 @@ class ConfinementTimeParam(NamedTuple): nd_plasma_electrons_vol_avg: Any = None - nd_ions_total: Any = None + nd_plasma_ions_total_vol_avg: Any = None nd_electron_line: Any = None @@ -2590,7 +2596,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=6.1946504123280199, @@ -2632,7 +2638,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.96163409847948844, @@ -2674,7 +2680,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.1960655150953154, @@ -2716,7 +2722,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.78453691772934719, @@ -2758,7 +2764,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.1619079679077555, @@ -2800,7 +2806,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.7340642483550435, @@ -2842,7 +2848,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.1117392853827024, @@ -2884,7 +2890,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.84477227311274361, @@ -2926,7 +2932,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.6096667103064701, @@ -2968,7 +2974,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.67053301699102119, @@ -3010,7 +3016,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=2.1212580310552207, @@ -3052,7 +3058,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=50.095480115636271, @@ -3094,7 +3100,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=87.869318916638761, @@ -3136,7 +3142,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=28.562137619592285, @@ -3178,7 +3184,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.50082256309019457, @@ -3220,7 +3226,7 @@ class ConfinementTimeParam(NamedTuple): aspect=3, b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, - nd_ions_total=7.1529510234203251e19, + nd_plasma_ions_total_vol_avg=7.1529510234203251e19, nd_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.77961193402355955, @@ -3300,7 +3306,7 @@ def test_calculate_confinement_time(confinementtimeparam, monkeypatch, physics): aspect=confinementtimeparam.aspect, b_plasma_toroidal_on_axis=confinementtimeparam.b_plasma_toroidal_on_axis, nd_plasma_electrons_vol_avg=confinementtimeparam.nd_plasma_electrons_vol_avg, - nd_ions_total=confinementtimeparam.nd_ions_total, + nd_plasma_ions_total_vol_avg=confinementtimeparam.nd_plasma_ions_total_vol_avg, nd_electron_line=confinementtimeparam.nd_electron_line, eps=confinementtimeparam.eps, hfact=confinementtimeparam.hfact, @@ -3353,7 +3359,7 @@ def test_calculate_plasma_masses(): """Test calculate_plasma_masses()""" m_fuel_amu = 2.5 m_ions_total_amu = 3.0 - nd_ions_total = 1.0e20 + nd_plasma_ions_total_vol_avg = 1.0e20 nd_plasma_fuel_ions_vol_avg = 0.8e20 nd_plasma_alphas_vol_avg = 0.1e20 vol_plasma = 100.0 @@ -3368,7 +3374,7 @@ def test_calculate_plasma_masses(): ) = Physics.calculate_plasma_masses( m_fuel_amu=m_fuel_amu, m_ions_total_amu=m_ions_total_amu, - nd_ions_total=nd_ions_total, + nd_plasma_ions_total_vol_avg=nd_plasma_ions_total_vol_avg, nd_plasma_fuel_ions_vol_avg=nd_plasma_fuel_ions_vol_avg, nd_plasma_alphas_vol_avg=nd_plasma_alphas_vol_avg, vol_plasma=vol_plasma, diff --git a/tests/unit/test_plasma_profiles.py b/tests/unit/test_plasma_profiles.py index a926127b17..aabb34cd45 100644 --- a/tests/unit/test_plasma_profiles.py +++ b/tests/unit/test_plasma_profiles.py @@ -163,7 +163,7 @@ class PlasmaProfilesParam(NamedTuple): alphat: float = 0.0 - nd_ions_total: float = 0.0 + nd_plasma_ions_total_vol_avg: float = 0.0 nd_plasma_pedestal_electron: float = 0.0 @@ -236,7 +236,7 @@ class PlasmaProfilesParam(NamedTuple): f_temp_plasma_ion_electron=1, nd_electron_line=0.0, alphat=1.45, - nd_ions_total=6.9461125748017857e19, + nd_plasma_ions_total_vol_avg=6.9461125748017857e19, nd_plasma_pedestal_electron=6.1916268627398164e19, temp_plasma_ion_vol_avg_kev=12.9, radius_plasma_pedestal_density_norm=0.94000000000000006, @@ -281,7 +281,7 @@ class PlasmaProfilesParam(NamedTuple): f_temp_plasma_ion_electron=1, nd_electron_line=8.8687354645836431e19, alphat=1.45, - nd_ions_total=6.9461125748017857e19, + nd_plasma_ions_total_vol_avg=6.9461125748017857e19, nd_plasma_pedestal_electron=6.1916268627398164e19, temp_plasma_ion_vol_avg_kev=13.07, radius_plasma_pedestal_density_norm=0.94000000000000006, @@ -412,7 +412,9 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): monkeypatch.setattr(physics_variables, "alphat", plasmaprofilesparam.alphat) monkeypatch.setattr( - physics_variables, "nd_ions_total", plasmaprofilesparam.nd_ions_total + physics_variables, + "nd_plasma_ions_total_vol_avg", + plasmaprofilesparam.nd_plasma_ions_total_vol_avg, ) monkeypatch.setattr( diff --git a/tracking/tracking_data.py b/tracking/tracking_data.py index aeac14ced2..7c197dace9 100644 --- a/tracking/tracking_data.py +++ b/tracking/tracking_data.py @@ -151,7 +151,7 @@ class ProcessTracker: "TFCoil.n_tf_coils", "TFCoil.b_tf_inboard_peak_symmetric", "PFCoil.vs_cs_pf_total_pulse", - "Physics.nd_ions_total", + "Physics.nd_plasma_ions_total_vol_avg", "Time.t_burn", "Cost.divlife", "Cost.cdirt", From bf9ca5a11548124334f911bd0cc03d77f18f6e2d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:14:30 +0100 Subject: [PATCH 20/30] =?UTF-8?q?=F0=9F=94=84=20Updated=20variable=20names?= =?UTF-8?q?=20from=20`nd=5Felectron=5Fline`=20to=20`nd=5Fplasma=5Felectron?= =?UTF-8?q?=5Fline`=20across=20multiple=20files=20to=20enhance=20clarity?= =?UTF-8?q?=20and=20maintain=20consistency=20in=20the=20codebase.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NBI/culham_nb.md | 2 +- .../profiles/plasma_profiles.md | 10 ++-- .../data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_3_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/confinement_time.py | 8 ++-- process/constraints.py | 6 +-- process/current_drive.py | 14 +++--- process/data_structure/physics_variables.py | 8 ++-- process/io/plot_proc.py | 8 ++-- process/io/variable_metadata.py | 2 +- process/physics.py | 46 ++++++++++--------- process/plasma_profiles.py | 4 +- process/stellarator.py | 18 ++++---- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/test_physics.py | 36 +++++++-------- tests/unit/test_plasma_profiles.py | 12 +++-- tests/unit/test_stellarator.py | 10 ++-- 22 files changed, 104 insertions(+), 96 deletions(-) diff --git a/documentation/eng-models/heating_and_current_drive/NBI/culham_nb.md b/documentation/eng-models/heating_and_current_drive/NBI/culham_nb.md index c90c3c99b8..46f29d18c4 100644 --- a/documentation/eng-models/heating_and_current_drive/NBI/culham_nb.md +++ b/documentation/eng-models/heating_and_current_drive/NBI/culham_nb.md @@ -71,7 +71,7 @@ plus correction terms outlined in Culham Report AEA FUS 172. | $\mathtt{alphat}$, $\alpha_T$ | temperature profile factor | | $\mathtt{aspect}$, $A$ | aspect ratio | | $\mathtt{nd_plasma_electrons_vol_avg}$, $n_{\text{e}}$ | volume averaged electron density $(\text{m}^{-3})$ | -| $\mathtt{nd_electron_line}$, $n_{\text{e,0}}$ | line averaged electron density $(\text{m}^{-3})$ | +| $\mathtt{nd_plasma_electron_line}$, $n_{\text{e,0}}$ | line averaged electron density $(\text{m}^{-3})$ | | $\mathtt{e_beam_kev}$ | neutral beam energy $(\text{keV})$ | | $\mathtt{f_radius_beam_tangency_rmajor}$ | R_tangent / R_major for neutral beam injection | | $\mathtt{fshine}$ | shine-through fraction of beam | diff --git a/documentation/physics-models/profiles/plasma_profiles.md b/documentation/physics-models/profiles/plasma_profiles.md index 107661c97f..93ca6922e9 100644 --- a/documentation/physics-models/profiles/plasma_profiles.md +++ b/documentation/physics-models/profiles/plasma_profiles.md @@ -282,23 +282,23 @@ The line averaged density is then calculated for the profile paramaters Line averaged electron density is calculated by integrating the profile across the normalised width of the profile and then dividing by the width of the integration bounds $$ -\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_electron_line}} = \frac{\int^1_0 n_0(1-\rho^2)^{\alpha_n} \ d\rho}{\rho} +\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_plasma_electron_line}} = \frac{\int^1_0 n_0(1-\rho^2)^{\alpha_n} \ d\rho}{\rho} $$ This can be more easily represented in radial coordinates and returning $\rho = \frac{r}{a}$ $$ -\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_electron_line}} = \frac{\int^a_0 n_0(1-r^2/a^2)^{\alpha_n} \ dr}{a} +\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_plasma_electron_line}} = \frac{\int^a_0 n_0(1-r^2/a^2)^{\alpha_n} \ dr}{a} $$ $$ -\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_electron_line}} = \frac{\left[\frac{an_0}{2}\frac{\Gamma(1/2)\Gamma(\alpha_n+1)}{\Gamma(\alpha_n+3/2)}\right]}{a} +\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_plasma_electron_line}} = \frac{\left[\frac{an_0}{2}\frac{\Gamma(1/2)\Gamma(\alpha_n+1)}{\Gamma(\alpha_n+3/2)}\right]}{a} $$ $\Gamma$ is the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) and is calculated in the code with [scipy.special.gamma()](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gamma.html) $$ -\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_electron_line}} = \frac{n_0}{2}\frac{\Gamma(1/2)\Gamma(\alpha_n+1)}{\Gamma(\alpha_n+3/2)} +\overbrace{\bar{n_{\text{e}}}}^{\texttt{nd_plasma_electron_line}} = \frac{n_0}{2}\frac{\Gamma(1/2)\Gamma(\alpha_n+1)}{\Gamma(\alpha_n+3/2)} $$ This is in agreement with the derivation from the ITER Physics Design 1989 [^2] @@ -605,7 +605,7 @@ $$ Calculate the line averaged electron density by integrating the normalised profile using the class [`integrate_profile_y()`](./plasma_profiles_abstract_class.md#calculate-the-profile-integral-value-integrate_profile_y) function $$ -\texttt{nd_electron_line} = \int_0^1{n(\rho) \ d\rho} +\texttt{nd_plasma_electron_line} = \int_0^1{n(\rho) \ d\rho} $$ A divertor variable `prn1` is set to be equal to the separatrix density over the mean density: diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index 6e8201aeb7..3e9a8c55aa 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -367,7 +367,7 @@ Electron_temp.,_density_weighted_(keV)__________________________________ (temp_plasma_electron_density_weighted_kev)_________________________ 1.3514E+01 Electron_density_(/m3)__________________________________________________ (nd_plasma_electrons_vol_avg)________________________ 8.0995E+19 ITV Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0654E+20 OP - Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9697E+19 OP + Line-averaged_electron_density_(/m3)____________________________________ (nd_plasma_electron_line)________________________ 8.9697E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.2127E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.5392E+19 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index f3cb861c64..aa18245b23 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -368,7 +368,7 @@ Electron_temp.,_density_weighted_(keV)__________________________________ (temp_plasma_electron_density_weighted_kev)_________________________ 1.3805E+01 Electron_density_(/m3)__________________________________________________ (nd_plasma_electrons_vol_avg)________________________ 8.0667E+19 ITV Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP - Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP + Line-averaged_electron_density_(/m3)____________________________________ (nd_plasma_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index 7afc204cb2..beda5c75c0 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -368,7 +368,7 @@ Electron_temp.,_density_weighted_(keV)__________________________________ (temp_plasma_electron_density_weighted_kev)_________________________ 1.3805E+01 Electron_density_(/m3)__________________________________________________ (nd_plasma_electrons_vol_avg)________________________ 8.0667E+19 ITV Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP - Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP + Line-averaged_electron_density_(/m3)____________________________________ (nd_plasma_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 4d58d6ee40..bdc7943bc3 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -368,7 +368,7 @@ Electron_temp.,_density_weighted_(keV)__________________________________ (temp_plasma_electron_density_weighted_kev)_________________________ 1.3805E+01 Electron_density_(/m3)__________________________________________________ (nd_plasma_electrons_vol_avg)________________________ 8.0667E+19 ITV Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP - Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP + Line-averaged_electron_density_(/m3)____________________________________ (nd_plasma_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index 60ea0c9c2b..189a3fe2ca 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -368,7 +368,7 @@ Electron_temp.,_density_weighted_(keV)__________________________________ (temp_plasma_electron_density_weighted_kev)_________________________ 1.3805E+01 Electron_density_(/m3)__________________________________________________ (nd_plasma_electrons_vol_avg)________________________ 8.0667E+19 ITV Electron_density_on_axis_(/m3)__________________________________________ (nd_plasma_electron_on_axis)_________________________ 1.0610E+20 OP - Line-averaged_electron_density_(/m3)____________________________________ (nd_electron_line)________________________ 8.9334E+19 OP + Line-averaged_electron_density_(/m3)____________________________________ (nd_plasma_electron_line)________________________ 8.9334E+19 OP Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index de6654c22a..37d128d93a 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -230,7 +230,7 @@ Electron_temp.,_density_weighted_(keV)___________________________________ (temp_plasma_electron_density_weighted_kev)__________________________ 1.34914174066700241e+01 OP Volume_averaged_electron_number_density_(/m3)____________________________ (nd_plasma_electrons_vol_avg)_________________________ 7.79622390002983731e+19 Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.02466460344915771e+20 OP - Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_________________________ 8.63127495812675338e+19 OP + Line-averaged_electron_number_density_(/m3)______________________________ (nd_plasma_electron_line)_________________________ 8.63127495812675338e+19 OP Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_thermal_on_axis)___________________________ 7.82668759018785902e+05 OP Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.26860509860517632e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19833068191158598e+00 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 8f726363c4..ca47af468e 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -302,7 +302,7 @@ Electron_temp.,_density_weighted_(keV)___________________________________ (temp_plasma_electron_density_weighted_kev)__________________________ 1.44360335891099503e+01 OP Volume_averaged_electron_number_density_(/m3)____________________________ (nd_plasma_electrons_vol_avg)_________________________ 8.50078961768999158e+19 Electron_number_density_on_axis_(/m3)____________________________________ (nd_plasma_electron_on_axis)__________________________ 1.11814263037413868e+20 OP - Line-averaged_electron_number_density_(/m3)______________________________ (nd_electron_line)_________________________ 9.41418090734859715e+19 OP + Line-averaged_electron_number_density_(/m3)______________________________ (nd_plasma_electron_line)_________________________ 9.41418090734859715e+19 OP Plasma_pressure_on_axis_(Pa)_____________________________________________ (pres_plasma_thermal_on_axis)___________________________ 9.10652371594472905e+05 OP Volume_averaged_plasma_pressure_(Pa)_____________________________________ (pres_plasma_thermal_vol_avg)_____________ 2.63957209157818230e+05 OP Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999999999999951e+00 OP diff --git a/process/confinement_time.py b/process/confinement_time.py index a6b26a9345..108cdafff8 100644 --- a/process/confinement_time.py +++ b/process/confinement_time.py @@ -1724,7 +1724,7 @@ def petty08_confinement_time( def lang_high_density_confinement_time( plasma_current: float, b_plasma_toroidal_on_axis: float, - nd_electron_line: float, + nd_plasma_electron_line: float, p_plasma_loss_mw: float, rmajor: float, rminor: float, @@ -1740,7 +1740,7 @@ def lang_high_density_confinement_time( Parameters: plasma_current (float): Plasma current [MA] b_plasma_toroidal_on_axis (float): Toroidal magnetic field [T] - nd_electron_line (float): Line averaged electron density [m**-3] + nd_plasma_electron_line (float): Line averaged electron density [m**-3] p_plasma_loss_mw (float): Net Heating power [MW] rmajor (float): Plasma major radius [m] rminor (float): Plasma minor radius [m] @@ -1763,12 +1763,12 @@ def lang_high_density_confinement_time( """ qratio = q / qstar n_gw = 1.0e14 * plasma_current / (np.pi * rminor * rminor) - nratio = nd_electron_line / n_gw + nratio = nd_plasma_electron_line / n_gw return ( 6.94e-7 * plasma_current**1.3678e0 * b_plasma_toroidal_on_axis**0.12e0 - * nd_electron_line**0.032236e0 + * nd_plasma_electron_line**0.032236e0 * (p_plasma_loss_mw * 1.0e6) ** (-0.74e0) * rmajor**1.2345e0 * kappa_ipb**0.37e0 diff --git a/process/constraints.py b/process/constraints.py index 66982aeb51..b42b3065e1 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -358,7 +358,7 @@ def constraint_equation_5(): fdene: f-value for density limit nd_plasma_electrons_vol_avg: electron density (/m3) dnelimt: density limit (/m3) - nd_electron_line: line averaged electron density (m-3) + nd_plasma_electron_line: line averaged electron density (m-3) i_density_limit: - 1 old ASDEX; @@ -372,14 +372,14 @@ def constraint_equation_5(): # Apply Greenwald limit to line-averaged density if data_structure.physics_variables.i_density_limit == 7: return ConstraintResult( - data_structure.physics_variables.nd_electron_line + data_structure.physics_variables.nd_plasma_electron_line / data_structure.physics_variables.dnelimt - 1.0 * data_structure.constraint_variables.fdene, data_structure.constraint_variables.fdene * data_structure.physics_variables.dnelimt, data_structure.constraint_variables.fdene * data_structure.physics_variables.dnelimt - - data_structure.physics_variables.nd_electron_line, + - data_structure.physics_variables.nd_plasma_electron_line, ) cc = ( diff --git a/process/current_drive.py b/process/current_drive.py index 92e0e4d140..bae7aa8676 100644 --- a/process/current_drive.py +++ b/process/current_drive.py @@ -150,12 +150,14 @@ def culnbi(self): # Calculate number of decay lengths to centre current_drive_variables.n_beam_decay_lengths_core = ( - dpath * physics_variables.nd_electron_line * sigstop + dpath * physics_variables.nd_plasma_electron_line * sigstop ) # Shine-through fraction of beam - fshine = np.exp(-2.0e0 * dpath * physics_variables.nd_electron_line * sigstop) + fshine = np.exp( + -2.0e0 * dpath * physics_variables.nd_plasma_electron_line * sigstop + ) fshine = max(fshine, 1.0e-20) # Deuterium and tritium beam densities @@ -189,7 +191,7 @@ def culnbi(self): physics_variables.alphat, physics_variables.aspect, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, current_drive_variables.e_beam_kev, current_drive_variables.f_radius_beam_tangency_rmajor, fshine, @@ -208,7 +210,7 @@ def etanb2( alphat, aspect, nd_plasma_electrons_vol_avg, - nd_electron_line, + nd_plasma_electron_line, e_beam_kev, f_radius_beam_tangency_rmajor, fshine, @@ -226,7 +228,7 @@ def etanb2( alphat : input real : temperature profile factor aspect : input real : aspect ratio nd_plasma_electrons_vol_avg : input real : volume averaged electron density (m**-3) - nd_electron_line : input real : line averaged electron density (m**-3) + nd_plasma_electron_line : input real : line averaged electron density (m**-3) e_beam_kev : input real : neutral beam energy (keV) f_radius_beam_tangency_rmajor : input real : R_tangent / R_major for neutral beam injection fshine : input real : shine-through fraction of beam @@ -252,7 +254,7 @@ def etanb2( dene20 = nd_plasma_electrons_vol_avg / 1e20 # Line averaged electron density (10**20 m**-3) - dnla20 = nd_electron_line / 1e20 + dnla20 = nd_plasma_electron_line / 1e20 # Critical energy (MeV) (power to electrons = power to ions) (IPDG89) # N.B. temp_plasma_electron_density_weighted_kev is in keV diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index bf08c718c3..ac39f0fe17 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -390,8 +390,8 @@ """Plasma volume averaged total ion density (/m3)""" -nd_electron_line: float = None -"""line averaged electron density (/m3)""" +nd_plasma_electron_line: float = None +"""Plasma line averaged electron density (/m3)""" nd_plasma_protons_vol_avg: float = None @@ -1419,7 +1419,7 @@ def init_physics_variables(): global beta_norm_max_stambaugh global dnelimt global nd_plasma_ions_total_vol_avg - global nd_electron_line + global nd_plasma_electron_line global nd_plasma_protons_vol_avg global ntau global nTtau @@ -1672,7 +1672,7 @@ def init_physics_variables(): beta_norm_max_stambaugh = 0.0 dnelimt = 0.0 nd_plasma_ions_total_vol_avg = 0.0 - nd_electron_line = 0.0 + nd_plasma_electron_line = 0.0 nd_plasma_protons_vol_avg = 0.0 ntau = 0.0 nTtau = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index fc4bc3d652..069af4ec11 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3658,7 +3658,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): f"{ne0 / nd_plasma_electrons_vol_avg:.3f}", rf"$\rho_{{\text{{ped,n}}}}$: {radius_plasma_pedestal_density_norm:.3f}" r"$ \hspace{8} \frac{\overline{n_{e}}}{n_{\text{GW}}}$: " - f"{mfile_data.data['nd_electron_line'].get_scan(scan) / mfile_data.data['dlimit(7)'].get_scan(scan):.3f}", + f"{mfile_data.data['nd_plasma_electron_line'].get_scan(scan) / mfile_data.data['dlimit(7)'].get_scan(scan):.3f}", rf"$n_{{\text{{e,sep}}}}$: {nd_plasma_separatrix_electron:.3e} m$^{{-3}}$", rf"$f_{{\text{{GW e,sep}}}}$: {fgwsep_out:.3f}", )) @@ -6838,7 +6838,7 @@ def plot_physics_info(axis, mfile_data, scan): axis.set_autoscaley_on(False) axis.set_autoscalex_on(False) - nong = mfile_data.data["nd_electron_line"].get_scan(scan) / mfile_data.data[ + nong = mfile_data.data["nd_plasma_electron_line"].get_scan(scan) / mfile_data.data[ "dlimit(7)" ].get_scan(scan) @@ -7607,7 +7607,7 @@ def plot_confinement_time_comparison( rmajor = mfile_data.data["rmajor"].get_scan(scan) c_plasma_ma = mfile_data.data["plasma_current_ma"].get_scan(scan) kappa95 = mfile_data.data["kappa95"].get_scan(scan) - dnla20 = mfile_data.data["nd_electron_line"].get_scan(scan) / 1e20 + dnla20 = mfile_data.data["nd_plasma_electron_line"].get_scan(scan) / 1e20 afuel = mfile_data.data["m_fuel_amu"].get_scan(scan) b_plasma_toroidal_on_axis = mfile_data.data["b_plasma_toroidal_on_axis"].get_scan( scan @@ -7615,7 +7615,7 @@ def plot_confinement_time_comparison( p_plasma_separatrix_mw = mfile_data.data["p_plasma_separatrix_mw"].get_scan(scan) kappa = mfile_data.data["kappa"].get_scan(scan) aspect = mfile_data.data["aspect"].get_scan(scan) - dnla19 = mfile_data.data["nd_electron_line"].get_scan(scan) / 1e19 + dnla19 = mfile_data.data["nd_plasma_electron_line"].get_scan(scan) / 1e19 kappa_ipb = mfile_data.data["kappa_ipb"].get_scan(scan) triang = mfile_data.data["triang"].get_scan(scan) m_ions_total_amu = mfile_data.data["m_ions_total_amu"].get_scan(scan) diff --git a/process/io/variable_metadata.py b/process/io/variable_metadata.py index a1fb928cda..04d94c5411 100644 --- a/process/io/variable_metadata.py +++ b/process/io/variable_metadata.py @@ -184,7 +184,7 @@ class VariableMetadata: description="Bore radius", units="m", ), - "nd_electron_line": VariableMetadata( + "nd_plasma_electron_line": VariableMetadata( latex=r"$\bar{n}_{\mathrm{e}}$[$m^{-3}$]", description="Average electron density", units="m^{-3}", diff --git a/process/physics.py b/process/physics.py index ce142a0627..1bd2be78c7 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2387,7 +2387,7 @@ def physics(self): # Calculate L- to H-mode power threshold for different scalings physics_variables.l_h_threshold_powers = l_h_threshold_power( - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, physics_variables.b_plasma_toroidal_on_axis, physics_variables.rmajor, physics_variables.rminor, @@ -2492,7 +2492,7 @@ def physics(self): physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, physics_variables.eps, physics_variables.hfact, physics_variables.i_confinement_time, @@ -3909,7 +3909,7 @@ def outplas(self): * physics_variables.rmajor**2 * physics_variables.b_plasma_toroidal_on_axis * np.sqrt(physics_variables.eps) - * physics_variables.nd_electron_line**3 + * physics_variables.nd_plasma_electron_line**3 * physics_variables.kappa / (physics_variables.e_plasma_beta**2 * physics_variables.plasma_current) ) @@ -3922,7 +3922,7 @@ def outplas(self): / ( 3.0e0 * physics_variables.vol_plasma - * physics_variables.nd_electron_line + * physics_variables.nd_plasma_electron_line ) ) / ( constants.ELECTRON_CHARGE @@ -4626,8 +4626,8 @@ def outplas(self): po.ovarre( self.outfile, "Line-averaged electron number density (/m3)", - "(nd_electron_line)", - physics_variables.nd_electron_line, + "(nd_plasma_electron_line)", + physics_variables.nd_plasma_electron_line, "OP ", ) po.ovarre( @@ -4680,7 +4680,7 @@ def outplas(self): self.outfile, "Line-averaged electron density / Greenwald density", "(dnla_gw)", - physics_variables.nd_electron_line / physics_variables.dlimit[6], + physics_variables.nd_plasma_electron_line / physics_variables.dlimit[6], "OP ", ) @@ -5890,14 +5890,16 @@ def outplas(self): ) logger.warning("rmajor outside Snipes 2000 fitted range") - if (physics_variables.nd_electron_line < 0.09e20) or ( - physics_variables.nd_electron_line > 3.16e20 + if (physics_variables.nd_plasma_electron_line < 0.09e20) or ( + physics_variables.nd_plasma_electron_line > 3.16e20 ): po.ocmmnt( self.outfile, - "(physics_variables.nd_electron_line outside Snipes 2000 fitted range)", + "(physics_variables.nd_plasma_electron_line outside Snipes 2000 fitted range)", + ) + logger.warning( + "nd_plasma_electron_line outside Snipes 2000 fitted range" ) - logger.warning("nd_electron_line outside Snipes 2000 fitted range") if (physics_variables.kappa < 1.0e0) or ( physics_variables.kappa > 2.04e0 @@ -6638,7 +6640,7 @@ def output_confinement_comparison(self, istell: int) -> None: physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, physics_variables.eps, 1.0, i_confinement_time, @@ -7568,7 +7570,7 @@ def fhz(hfact: float) -> float: physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, physics_variables.eps, hfact, i_confinement_time, @@ -7624,7 +7626,7 @@ def calculate_confinement_time( b_plasma_toroidal_on_axis: float, nd_plasma_ions_total_vol_avg: float, nd_plasma_electrons_vol_avg: float, - nd_electron_line: float, + nd_plasma_electron_line: float, eps: float, hfact: float, i_confinement_time: int, @@ -7653,7 +7655,7 @@ def calculate_confinement_time( :param b_plasma_toroidal_on_axis: Toroidal field on axis (T) :param nd_plasma_ions_total_vol_avg: Total ion density (/m3) :param nd_plasma_electrons_vol_avg: Volume averaged electron density (/m3) - :param nd_electron_line: Line-averaged electron density (/m3) + :param nd_plasma_electron_line: Line-averaged electron density (/m3) :param eps: Inverse aspect ratio :param hfact: H factor on energy confinement scalings :param i_confinement_time: Switch for energy confinement scaling to use @@ -7713,8 +7715,8 @@ def calculate_confinement_time( # ======================================================================== # Line averaged electron density in scaled units - dnla20 = nd_electron_line * 1.0e-20 - dnla19 = nd_electron_line * 1.0e-19 + dnla20 = nd_plasma_electron_line * 1.0e-20 + dnla19 = nd_plasma_electron_line * 1.0e-19 # Volume averaged electron density in units of 10**20 m**-3 n20 = nd_plasma_electrons_vol_avg / 1.0e20 @@ -8328,7 +8330,7 @@ def calculate_confinement_time( t_electron_confinement = confinement.lang_high_density_confinement_time( plasma_current, b_plasma_toroidal_on_axis, - nd_electron_line, + nd_plasma_electron_line, p_plasma_loss_mw, rmajor, rminor, @@ -8594,7 +8596,7 @@ def res_diff_time(rmajor, res_plasma, kappa95): def l_h_threshold_power( - nd_electron_line: float, + nd_plasma_electron_line: float, b_plasma_toroidal_on_axis: float, rmajor: float, rminor: float, @@ -8607,8 +8609,8 @@ def l_h_threshold_power( """ L-mode to H-mode power threshold calculation. - :param nd_electron_line: Line-averaged electron density (/m3) - :type nd_electron_line: float + :param nd_plasma_electron_line: Line-averaged electron density (/m3) + :type nd_plasma_electron_line: float :param b_plasma_toroidal_on_axis: Toroidal field on axis (T) :type b_plasma_toroidal_on_axis: float :param rmajor: Plasma major radius (m) @@ -8630,7 +8632,7 @@ def l_h_threshold_power( :rtype: list[float] """ - dnla20 = 1e-20 * nd_electron_line + dnla20 = 1e-20 * nd_plasma_electron_line # ======================================================================== diff --git a/process/plasma_profiles.py b/process/plasma_profiles.py index a203fd09cf..2953afd120 100644 --- a/process/plasma_profiles.py +++ b/process/plasma_profiles.py @@ -151,7 +151,7 @@ def parabolic_paramterisation(self) -> None: # Line averaged electron density (IPDG89) # Taken by integrating the parabolic profile over rho in the bounds of 0 and 1 and dividng by the width of the integration bounds - physics_variables.nd_electron_line = ( + physics_variables.nd_plasma_electron_line = ( physics_variables.nd_plasma_electrons_vol_avg * (1.0 + physics_variables.alphan) * (sp.special.gamma(0.5) / 2.0) @@ -245,7 +245,7 @@ def pedestal_parameterisation(self) -> None: # Line-averaged electron density # = integral(n(rho).drho) - physics_variables.nd_electron_line = self.neprofile.profile_integ + physics_variables.nd_plasma_electron_line = self.neprofile.profile_integ # Scrape-off density / volume averaged density # (Input value is used if i_plasma_pedestal = 0) diff --git a/process/stellarator.py b/process/stellarator.py index d3198982bc..ca91c8f91a 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -3689,7 +3689,7 @@ def stdlim(self, b_plasma_toroidal_on_axis, powht, rmajor, rminor): dlimit = ( dnlamx * physics_variables.nd_plasma_electrons_vol_avg - / physics_variables.nd_electron_line + / physics_variables.nd_plasma_electron_line ) # Set the required value for icc=5 @@ -4287,7 +4287,7 @@ def stphys(self, output): / ( 3.0e0 * physics_variables.vol_plasma - * physics_variables.nd_electron_line + * physics_variables.nd_plasma_electron_line ) ) / ( constants.ELECTRON_CHARGE @@ -4606,7 +4606,7 @@ def stphys(self, output): physics_variables.b_plasma_toroidal_on_axis, physics_variables.nd_plasma_ions_total_vol_avg, physics_variables.nd_plasma_electrons_vol_avg, - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, physics_variables.eps, physics_variables.hfact, physics_variables.i_confinement_time, @@ -4722,7 +4722,7 @@ def stphys(self, output): nu_star_d, nu_star_T, nu_star_He, - physics_variables.nd_electron_line, + physics_variables.nd_plasma_electron_line, physics_variables.dnelimt, ) @@ -4746,7 +4746,7 @@ def stphys_output( nu_star_D, nu_star_T, nu_star_He, - nd_electron_line, + nd_plasma_electron_line, dnelimt, ): po.oheadr(self.outfile, "Stellarator Specific Physics:") @@ -4854,15 +4854,15 @@ def stphys_output( po.ovarre( self.outfile, "Obtained line averaged density at op. point (/m3)", - "(nd_electron_line)", - nd_electron_line, + "(nd_plasma_electron_line)", + nd_plasma_electron_line, ) po.ovarre(self.outfile, "Sudo density limit (/m3)", "(dnelimt)", dnelimt) po.ovarre( self.outfile, "Ratio density to sudo limit (1)", - "(nd_electron_line/dnelimt)", - nd_electron_line / dnelimt, + "(nd_plasma_electron_line/dnelimt)", + nd_plasma_electron_line / dnelimt, ) def calc_neoclassics(self): diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index d176c076fb..d1492a003e 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -237,7 +237,7 @@ triang = 0.5 icc = 5 * DESCRIPTION: Density Upper Limit * JUSTIFICATION: Used to enforce Greenwald limit -* VARIABLES: dnelimt & nd_electron_line calculated in-situ +* VARIABLES: dnelimt & nd_plasma_electron_line calculated in-situ i_density_limit = 7 * DESCRIPTION: Switch for Density Limit to Enforce (icc=5) (7: Greenwald Limit) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index b059de0107..ba84f26529 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -2524,7 +2524,7 @@ class ConfinementTimeParam(NamedTuple): nd_plasma_ions_total_vol_avg: Any = None - nd_electron_line: Any = None + nd_plasma_electron_line: Any = None eps: Any = None @@ -2597,7 +2597,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=6.1946504123280199, kappa=1.8500000000000001, @@ -2639,7 +2639,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.96163409847948844, kappa=1.8500000000000001, @@ -2681,7 +2681,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.1960655150953154, kappa=1.8500000000000001, @@ -2723,7 +2723,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.78453691772934719, kappa=1.8500000000000001, @@ -2765,7 +2765,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.1619079679077555, kappa=1.8500000000000001, @@ -2807,7 +2807,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.7340642483550435, kappa=1.8500000000000001, @@ -2849,7 +2849,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.1117392853827024, kappa=1.8500000000000001, @@ -2891,7 +2891,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.84477227311274361, kappa=1.8500000000000001, @@ -2933,7 +2933,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=1.6096667103064701, kappa=1.8500000000000001, @@ -2975,7 +2975,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.67053301699102119, kappa=1.8500000000000001, @@ -3017,7 +3017,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=2.1212580310552207, kappa=1.8500000000000001, @@ -3059,7 +3059,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=50.095480115636271, kappa=1.8500000000000001, @@ -3101,7 +3101,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=87.869318916638761, kappa=1.8500000000000001, @@ -3143,7 +3143,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=28.562137619592285, kappa=1.8500000000000001, @@ -3185,7 +3185,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.50082256309019457, kappa=1.8500000000000001, @@ -3227,7 +3227,7 @@ class ConfinementTimeParam(NamedTuple): b_plasma_toroidal_on_axis=5.2375830857646202, nd_plasma_electrons_vol_avg=8.0593948787884524e19, nd_plasma_ions_total_vol_avg=7.1529510234203251e19, - nd_electron_line=8.925359201116491e19, + nd_plasma_electron_line=8.925359201116491e19, eps=0.33333333333333331, hfact=0.77961193402355955, kappa=1.8500000000000001, @@ -3307,7 +3307,7 @@ def test_calculate_confinement_time(confinementtimeparam, monkeypatch, physics): b_plasma_toroidal_on_axis=confinementtimeparam.b_plasma_toroidal_on_axis, nd_plasma_electrons_vol_avg=confinementtimeparam.nd_plasma_electrons_vol_avg, nd_plasma_ions_total_vol_avg=confinementtimeparam.nd_plasma_ions_total_vol_avg, - nd_electron_line=confinementtimeparam.nd_electron_line, + nd_plasma_electron_line=confinementtimeparam.nd_plasma_electron_line, eps=confinementtimeparam.eps, hfact=confinementtimeparam.hfact, kappa=confinementtimeparam.kappa, diff --git a/tests/unit/test_plasma_profiles.py b/tests/unit/test_plasma_profiles.py index aabb34cd45..3d08682b0f 100644 --- a/tests/unit/test_plasma_profiles.py +++ b/tests/unit/test_plasma_profiles.py @@ -159,7 +159,7 @@ class PlasmaProfilesParam(NamedTuple): f_temp_plasma_ion_electron: float = 0.0 - nd_electron_line: float = 0.0 + nd_plasma_electron_line: float = 0.0 alphat: float = 0.0 @@ -234,7 +234,7 @@ class PlasmaProfilesParam(NamedTuple): nd_plasma_electron_on_axis=0.0, temp_plasma_ion_on_axis_kev=0.0, f_temp_plasma_ion_electron=1, - nd_electron_line=0.0, + nd_plasma_electron_line=0.0, alphat=1.45, nd_plasma_ions_total_vol_avg=6.9461125748017857e19, nd_plasma_pedestal_electron=6.1916268627398164e19, @@ -279,7 +279,7 @@ class PlasmaProfilesParam(NamedTuple): nd_plasma_electron_on_axis=1.0585658890823703e20, temp_plasma_ion_on_axis_kev=27.369013322953624, f_temp_plasma_ion_electron=1, - nd_electron_line=8.8687354645836431e19, + nd_plasma_electron_line=8.8687354645836431e19, alphat=1.45, nd_plasma_ions_total_vol_avg=6.9461125748017857e19, nd_plasma_pedestal_electron=6.1916268627398164e19, @@ -406,7 +406,9 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): ) monkeypatch.setattr( - physics_variables, "nd_electron_line", plasmaprofilesparam.nd_electron_line + physics_variables, + "nd_plasma_electron_line", + plasmaprofilesparam.nd_plasma_electron_line, ) monkeypatch.setattr(physics_variables, "alphat", plasmaprofilesparam.alphat) @@ -508,7 +510,7 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): plasmaprofilesparam.expected_ti0 ) - assert physics_variables.nd_electron_line == pytest.approx( + assert physics_variables.nd_plasma_electron_line == pytest.approx( plasmaprofilesparam.expected_nd_electron_line ) diff --git a/tests/unit/test_stellarator.py b/tests/unit/test_stellarator.py index d958f046b0..4043c2da12 100644 --- a/tests/unit/test_stellarator.py +++ b/tests/unit/test_stellarator.py @@ -2621,7 +2621,7 @@ def test_intersect(intersectparam, stellarator): class StdlimParam(NamedTuple): nd_plasma_electrons_vol_avg: Any = None - nd_electron_line: Any = None + nd_plasma_electron_line: Any = None dnelimt: Any = None @@ -2643,7 +2643,7 @@ class StdlimParam(NamedTuple): ( StdlimParam( nd_plasma_electrons_vol_avg=2.0914e20, - nd_electron_line=2.357822619799476e20, + nd_plasma_electron_line=2.357822619799476e20, dnelimt=0, b_plasma_toroidal_on_axis=5.5, powht=432.20449197454559, @@ -2654,7 +2654,7 @@ class StdlimParam(NamedTuple): ), StdlimParam( nd_plasma_electrons_vol_avg=2.0914e20, - nd_electron_line=2.357822619799476e20, + nd_plasma_electron_line=2.357822619799476e20, dnelimt=1.2918765671497731e20, b_plasma_toroidal_on_axis=5.5, powht=431.98698920075435, @@ -2685,7 +2685,9 @@ def test_stdlim(stdlimparam, monkeypatch, stellarator): ) monkeypatch.setattr( - physics_variables, "nd_electron_line", stdlimparam.nd_electron_line + physics_variables, + "nd_plasma_electron_line", + stdlimparam.nd_plasma_electron_line, ) monkeypatch.setattr(physics_variables, "dnelimt", stdlimparam.dnelimt) From 0f7959d8c57d45eee158c10a4731f7cc6ff0a2ed Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:17:46 +0100 Subject: [PATCH 21/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`nd=5Fimpurities`?= =?UTF-8?q?=20to=20`nd=5Fplasma=5Fimpurities=5Fvol=5Favg`=20across=20multi?= =?UTF-8?q?ple=20files=20for=20clarity=20and=20consistency=20in=20plasma?= =?UTF-8?q?=20impurity=20density=20calculations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/physics-models/plasma_composition.md | 2 +- examples/data/csv_output_large_tokamak_MFILE.DAT | 2 +- examples/data/large_tokamak_1_MFILE.DAT | 2 +- examples/data/large_tokamak_2_MFILE.DAT | 2 +- examples/data/large_tokamak_3_MFILE.DAT | 2 +- examples/data/large_tokamak_4_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 8 ++++---- process/io/mfile_comparison.py | 2 +- process/io/plot_proc.py | 14 +++++++++----- process/physics.py | 10 +++++----- tests/unit/test_physics.py | 12 +++++++----- tracking/tracking_data.py | 2 +- 14 files changed, 35 insertions(+), 29 deletions(-) diff --git a/documentation/physics-models/plasma_composition.md b/documentation/physics-models/plasma_composition.md index 75b23fd389..9abb7f93d6 100644 --- a/documentation/physics-models/plasma_composition.md +++ b/documentation/physics-models/plasma_composition.md @@ -132,7 +132,7 @@ All of the plasma composites are normally given as a fraction of the volume aver 8. **Total Impurity Density Calculation** - - Calculate the total impurity density (`nd_impurities`). + - Calculate the total impurity density (`nd_plasma_impurities_vol_avg`). $$ \mathtt{nd\_impurities} | n_{\text{impurities}} = \sum_j n_{\text{e}} f_j diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index 3e9a8c55aa..fb6e97eb71 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -371,7 +371,7 @@ Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.2127E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.5392E+19 OP - Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6024E+16 OP + Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_plasma_impurities_vol_avg)_________________________ 4.6024E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.6709E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8502E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index aa18245b23..523871ed37 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -372,7 +372,7 @@ Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP - Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP + Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_plasma_impurities_vol_avg)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index beda5c75c0..e8d1a4296e 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -372,7 +372,7 @@ Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP - Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP + Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_plasma_impurities_vol_avg)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index bdc7943bc3..9a525f234d 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -372,7 +372,7 @@ Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP - Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP + Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_plasma_impurities_vol_avg)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protonstons)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index 189a3fe2ca..ed47282e69 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -372,7 +372,7 @@ Line-averaged_electron_density_/_Greenwald_density______________________ (dnla_gw)_____________________ 1.2000E+00 OP Ion_density_(/m3)_______________________________________________________ (nd_plasma_ions_total_vol_avg)______________________ 7.1669E+19 OP Fuel_density_(/m3)______________________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)________________________ 6.4831E+19 OP - Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_impurities)_________________________ 4.6503E+16 OP + Total_impurity_density_with_Z_>_2_(no_He)_(/m3)_________________________ (nd_plasma_impurities_vol_avg)_________________________ 4.6503E+16 OP Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 37d128d93a..89b77a0366 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -236,7 +236,7 @@ Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19833068191158598e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_plasma_ions_total_vol_avg)________________ 7.06084473006886912e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)_________________ 6.58453241268011663e+19 OP - Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 5.43985672856892960e+16 OP + Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_plasma_impurities_vol_avg)________________ 5.43985672856892960e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 4.69634891516571443e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 6.02387639886502110e-02 Proton_number_density_(/m3)______________________________________________ (nd_plasma_protons_vol_avg)___________________ 1.23756914361185080e+16 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index ca47af468e..e8858c8127 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -308,7 +308,7 @@ Line-averaged_electron_density_/_Greenwald_density_______________________ (dnla_gw)______________________ 1.19999999999999951e+00 OP Total_Ion_number_density_(/m3)___________________________________________ (nd_plasma_ions_total_vol_avg)________________ 7.34892735750798868e+19 OP Fuel_ion_number_density_(/m3)____________________________________________ (nd_plasma_fuel_ions_vol_avgel_ions_vol_avg)_________________ 6.49714589130413015e+19 OP - Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_impurities)________________ 6.41695061162086560e+16 OP + Total_impurity_number_density_with_Z_>_2_(no_He)_(/m3)___________________ (nd_plasma_impurities_vol_avg)________________ 6.41695061162086560e+16 OP Helium_ion_number_density_(thermalised_ions_only)_(/m3)__________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)____________________ 8.43080585227756646e+18 OP Helium_ion_density_(thermalised_ions_only)_/_electron_number_density_____ (f_nd_alpha_electron)__________ 9.91767380612879751e-02 Proton_number_density_(/m3)______________________________________________ (nd_plasma_protons_vol_avg)___________________ 2.28393036448186680e+16 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index ac39f0fe17..f7888bfee4 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -406,8 +406,8 @@ """Lawson triple product [keV s / m3]""" -nd_impurities: float = None -"""high Z ion density (/m3)""" +nd_plasma_impurities_vol_avg: float = None +"""Plasma volume averaged impurity (Z > 2) ion density (/m3)""" gradient_length_ne: float = None @@ -1423,7 +1423,7 @@ def init_physics_variables(): global nd_plasma_protons_vol_avg global ntau global nTtau - global nd_impurities + global nd_plasma_impurities_vol_avg global beta_poloidal_eps_max global eps global f_c_plasma_auxiliary @@ -1676,7 +1676,7 @@ def init_physics_variables(): nd_plasma_protons_vol_avg = 0.0 ntau = 0.0 nTtau = 0.0 - nd_impurities = 0.0 + nd_plasma_impurities_vol_avg = 0.0 beta_poloidal_eps_max = 1.38 eps = 0.34399724802 f_c_plasma_auxiliary = 0.0 diff --git a/process/io/mfile_comparison.py b/process/io/mfile_comparison.py index 172d8bad62..f3612f8409 100644 --- a/process/io/mfile_comparison.py +++ b/process/io/mfile_comparison.py @@ -129,7 +129,7 @@ "temp_plasma_pedestal_kev", "nd_plasma_pedestal_electron", "zeff", - "nd_impurities", + "nd_plasma_impurities_vol_avg", "t_energy_confinement", "hfact", "tauelaw", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 069af4ec11..5ffe61ffc7 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3682,7 +3682,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): r"$\langle n_{\text{alpha}} \rangle $: " f"{mfile_data.data['nd_plasma_alphas_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{impurities}} \rangle $: " - f"{mfile_data.data['nd_impurities'].get_scan(scan):.3e} m$^{{-3}}$", + f"{mfile_data.data['nd_plasma_impurities_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", r"$\langle n_{\text{protons}} \rangle $:" f"{mfile_data.data['nd_plasma_protons_vol_avg'].get_scan(scan):.3e} m$^{{-3}}$", )) @@ -6842,9 +6842,9 @@ def plot_physics_info(axis, mfile_data, scan): "dlimit(7)" ].get_scan(scan) - nd_impurities = mfile_data.data["nd_impurities"].get_scan(scan) / mfile_data.data[ - "nd_plasma_electrons_vol_avg" - ].get_scan(scan) + nd_plasma_impurities_vol_avg = mfile_data.data[ + "nd_plasma_impurities_vol_avg" + ].get_scan(scan) / mfile_data.data["nd_plasma_electrons_vol_avg"].get_scan(scan) tepeak = mfile_data.data["temp_plasma_electron_on_axis_kev"].get_scan( scan @@ -6877,7 +6877,11 @@ def plot_physics_info(axis, mfile_data, scan): (tepeak, r"$T_{e0} \ / \ \langle T_e \rangle$", ""), (nepeak, r"$n_{e0} \ / \ \langle n_{\mathrm{e, vol}} \rangle$", ""), ("zeff", r"$Z_{\mathrm{eff}}$", ""), - (nd_impurities, r"$n_Z \ / \ \langle n_{\mathrm{e, vol}} \rangle$", ""), + ( + nd_plasma_impurities_vol_avg, + r"$n_Z \ / \ \langle n_{\mathrm{e, vol}} \rangle$", + "", + ), ("t_energy_confinement", r"$\tau_e$", "s"), ("hfact", "H-factor", ""), (pthresh, "H-mode threshold", "MW"), diff --git a/process/physics.py b/process/physics.py index 1bd2be78c7..5bdc28f562 100644 --- a/process/physics.py +++ b/process/physics.py @@ -3323,10 +3323,10 @@ def plasma_composition() -> None: # ====================================================================== # Total impurity density - physics_variables.nd_impurities = 0.0 + physics_variables.nd_plasma_impurities_vol_avg = 0.0 for imp in range(impurity_radiation_module.N_IMPURITIES): if impurity_radiation_module.impurity_arr_z[imp] > 2: - physics_variables.nd_impurities += ( + physics_variables.nd_plasma_impurities_vol_avg += ( impurity_radiation_module.f_nd_impurity_electron_array[imp] * physics_variables.nd_plasma_electrons_vol_avg ) @@ -3339,7 +3339,7 @@ def plasma_composition() -> None: + physics_variables.nd_plasma_alphas_vol_avg + physics_variables.nd_plasma_protons_vol_avg + physics_variables.nd_beam_ions - + physics_variables.nd_impurities + + physics_variables.nd_plasma_impurities_vol_avg ) # ====================================================================== @@ -4701,8 +4701,8 @@ def outplas(self): po.ovarre( self.outfile, "Total impurity number density with Z > 2 (no He) (/m3)", - "(nd_impurities)", - physics_variables.nd_impurities, + "(nd_plasma_impurities_vol_avg)", + physics_variables.nd_plasma_impurities_vol_avg, "OP ", ) po.ovarre( diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index ba84f26529..ee6b2f9b2b 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -1394,7 +1394,7 @@ class PlasmaCompositionParam(NamedTuple): zeff: Any = None - nd_impurities: Any = None + nd_plasma_impurities_vol_avg: Any = None f_temp_plasma_electron_density_vol_avg: Any = None @@ -1547,7 +1547,7 @@ class PlasmaCompositionParam(NamedTuple): dlamee=0, f_nd_beam_electron=0, zeff=0, - nd_impurities=0, + nd_plasma_impurities_vol_avg=0, f_temp_plasma_electron_density_vol_avg=0, fusden_alpha_total=0, f_nd_plasma_iron_argon_electron=0, @@ -1665,7 +1665,7 @@ class PlasmaCompositionParam(NamedTuple): dlamee=17.510652035055571, f_nd_beam_electron=0, zeff=2.0909945616489103, - nd_impurities=28875000000000004, + nd_plasma_impurities_vol_avg=28875000000000004, f_temp_plasma_electron_density_vol_avg=1.0521775929921553, fusden_alpha_total=1.973996644759543e17, f_nd_plasma_iron_argon_electron=0, @@ -1837,7 +1837,9 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): monkeypatch.setattr(physics_variables, "zeff", plasmacompositionparam.zeff) monkeypatch.setattr( - physics_variables, "nd_impurities", plasmacompositionparam.nd_impurities + physics_variables, + "nd_plasma_impurities_vol_avg", + plasmacompositionparam.nd_plasma_impurities_vol_avg, ) monkeypatch.setattr( @@ -1972,7 +1974,7 @@ def test_plasma_composition(plasmacompositionparam, monkeypatch, physics): assert physics_variables.zeff == pytest.approx(plasmacompositionparam.expected_zeff) - assert physics_variables.nd_impurities == pytest.approx( + assert physics_variables.nd_plasma_impurities_vol_avg == pytest.approx( plasmacompositionparam.expected_nd_impurities ) diff --git a/tracking/tracking_data.py b/tracking/tracking_data.py index 7c197dace9..3773a4fe8e 100644 --- a/tracking/tracking_data.py +++ b/tracking/tracking_data.py @@ -137,7 +137,7 @@ class ProcessTracker: "Physics.p_plasma_rad_mw", "Physics.nd_plasma_electron_on_axis", "Physics.f_c_plasma_auxiliary", - "Physics.nd_impurities", + "Physics.nd_plasma_impurities_vol_avg", "Physics.t_energy_confinement", "Physics.temp_plasma_electron_on_axis_kev", "Physics.p_plasma_separatrix_mw", From 216a5971da520062174c4a207ad362ed11a7dc2d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:34:58 +0100 Subject: [PATCH 22/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`beta=5Fmax`=20to?= =?UTF-8?q?=20`beta=5Fvol=5Favg=5Fmax`=20across=20multiple=20files=20for?= =?UTF-8?q?=20clarity=20and=20consistency=20in=20plasma=20beta=20calculati?= =?UTF-8?q?ons.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/constraints.py | 24 +++++++++---------- process/data_structure/physics_variables.py | 8 +++---- process/input.py | 2 +- process/io/obsolete_vars.py | 2 +- process/physics.py | 16 ++++++------- process/stellarator.py | 2 +- tests/regression/input_files/helias_5b.IN.DAT | 2 +- .../input_files/st_regression.IN.DAT | 2 +- .../stellarator_helias_eval.IN.DAT | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 89b77a0366..fd2f52dcd9 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -201,7 +201,7 @@ Safety_factor_on_axis____________________________________________________ (q0)___________________________ 1.00000000000000000e+00 Safety_factor_at_95%_flux_surface________________________________________ (q95)__________________________ 3.73390781931285565e+00 Cylindrical_safety_factor_(qcyl)_________________________________________ (qstar)________________________ 4.12802018540024562e+00 OP - Upper_limit_on_thermal_beta______________________________________________ (beta_max)_____________________ 6.75897673577628422e-02 OP + Upper_limit_on_thermal_beta______________________________________________ (beta_vol_avg_max_avg_max)_____________________ 6.75897673577628422e-02 OP Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 3.23040881535548857e-02 Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index e8858c8127..cfb3df6431 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -273,7 +273,7 @@ Safety_factor_on_axis____________________________________________________ (q0)___________________________ 1.00000000000000000e+00 Safety_factor_at_95%_flux_surface________________________________________ (q95)__________________________ 3.05729664268825285e+00 Cylindrical_safety_factor_(qcyl)_________________________________________ (qstar)________________________ 3.37999298978303386e+00 OP - Upper_limit_on_thermal_beta______________________________________________ (beta_max)_____________________ 7.35303866910386600e-02 OP + Upper_limit_on_thermal_beta______________________________________________ (beta_vol_avg_max_avg_max)_____________________ 7.35303866910386600e-02 OP Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 4.48303922556954615e-02 Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP diff --git a/process/constraints.py b/process/constraints.py index b42b3065e1..e890cb384e 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -801,7 +801,7 @@ def constraint_equation_24(): - 0 use tokamak model; - 1 use stellarator model fbeta_max: f-value for beta limit - beta_max: allowable beta + beta_vol_avg_max: allowable beta beta_total_vol_avg: total plasma beta (calculated if i_plasma_pedestal =3) beta_fast_alpha: fast alpha beta component beta_beam: neutral beam beta component @@ -815,12 +815,12 @@ def constraint_equation_24(): ): cc = ( data_structure.physics_variables.beta_total_vol_avg - / data_structure.physics_variables.beta_max + / data_structure.physics_variables.beta_vol_avg_max - 1.0 * data_structure.constraint_variables.fbeta_max ) - con = data_structure.physics_variables.beta_max + con = data_structure.physics_variables.beta_vol_avg_max err = ( - data_structure.physics_variables.beta_max + data_structure.physics_variables.beta_vol_avg_max - data_structure.physics_variables.beta_total_vol_avg / data_structure.constraint_variables.fbeta_max ) @@ -832,12 +832,12 @@ def constraint_equation_24(): - data_structure.physics_variables.beta_fast_alpha - data_structure.physics_variables.beta_beam ) - / data_structure.physics_variables.beta_max + / data_structure.physics_variables.beta_vol_avg_max - 1.0 * data_structure.constraint_variables.fbeta_max ) - con = data_structure.physics_variables.beta_max + con = data_structure.physics_variables.beta_vol_avg_max err = ( - data_structure.physics_variables.beta_max + data_structure.physics_variables.beta_vol_avg_max - ( data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha @@ -852,10 +852,10 @@ def constraint_equation_24(): data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha ) - / data_structure.physics_variables.beta_max + / data_structure.physics_variables.beta_vol_avg_max - 1.0 * data_structure.constraint_variables.fbeta_max ) - con = data_structure.physics_variables.beta_max * (1.0 - cc) + con = data_structure.physics_variables.beta_vol_avg_max * (1.0 - cc) err = ( data_structure.physics_variables.beta_total_vol_avg - data_structure.physics_variables.beta_fast_alpha @@ -871,12 +871,12 @@ def constraint_equation_24(): ) ** 2 ) - / data_structure.physics_variables.beta_max + / data_structure.physics_variables.beta_vol_avg_max - 1.0 * data_structure.constraint_variables.fbeta_max ) - con = data_structure.physics_variables.beta_max + con = data_structure.physics_variables.beta_vol_avg_max err = ( - data_structure.physics_variables.beta_max + data_structure.physics_variables.beta_vol_avg_max - ( data_structure.physics_variables.beta_total_vol_avg * ( diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index f7888bfee4..b8cdcb22da 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -221,8 +221,8 @@ """fast alpha beta component""" -beta_max: float = None -"""Max allowable beta""" +beta_vol_avg_max: float = None +"""Max allowable volume averaged beta""" beta_min: float = None @@ -1377,7 +1377,7 @@ def init_physics_variables(): global beamfus0 global beta_total_vol_avg global beta_fast_alpha - global beta_max + global beta_vol_avg_max global beta_min global beta_beam global beta_poloidal_vol_avg @@ -1630,7 +1630,7 @@ def init_physics_variables(): beamfus0 = 1.0 beta_total_vol_avg = 0.042 beta_fast_alpha = 0.0 - beta_max = 0.0 + beta_vol_avg_max = 0.0 beta_min = 0.0 beta_beam = 0.0 beta_poloidal_vol_avg = 0.0 diff --git a/process/input.py b/process/input.py index 9a040afc5d..06292bdb5f 100644 --- a/process/input.py +++ b/process/input.py @@ -119,7 +119,7 @@ def __post_init__(self): "beta_total_vol_avg": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), - "beta_max": InputVariable( + "beta_vol_avg_max": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), "beta_min": InputVariable( diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 6d6fa6d0e5..bb7e7e839d 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -151,7 +151,7 @@ "epbetmax": "beta_poloidal_eps_max", "dnbeta": "beta_norm_max", "ifalphap": "i_beta_fast_alpha", - "betalim": "beta_max", + "betalim": "beta_vol_avg_max", "betalim_lower": "beta_min", "fbeta": "fbeta_poloidal_eps", "fcwr": "fr_conducting_wall", diff --git a/process/physics.py b/process/physics.py index 5bdc28f562..25e1bff9b1 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2643,8 +2643,8 @@ def physics(self): i_beta_norm_max=physics_variables.i_beta_norm_max, ) - # calculate_beta_limit() returns the beta_max for beta - physics_variables.beta_max = calculate_beta_limit( + # calculate_beta_limit() returns the beta_vol_avg_max for beta + physics_variables.beta_vol_avg_max = calculate_beta_limit( physics_variables.b_plasma_toroidal_on_axis, physics_variables.beta_norm_max, physics_variables.plasma_current, @@ -4321,24 +4321,24 @@ def outplas(self): po.ovarrf( self.outfile, "Upper limit on total beta", - "(beta_max)", - physics_variables.beta_max, + "(beta_vol_avg_max)", + physics_variables.beta_vol_avg_max, "OP ", ) elif physics_variables.i_beta_component == 1: po.ovarrf( self.outfile, "Upper limit on thermal beta", - "(beta_max)", - physics_variables.beta_max, + "(beta_vol_avg_max)", + physics_variables.beta_vol_avg_max, "OP ", ) else: po.ovarrf( self.outfile, "Upper limit on thermal + NB beta", - "(beta_max)", - physics_variables.beta_max, + "(beta_vol_avg_max)", + physics_variables.beta_vol_avg_max, "OP ", ) diff --git a/process/stellarator.py b/process/stellarator.py index ca91c8f91a..16132394e4 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -4669,7 +4669,7 @@ def stphys(self, output): ) # Calculate physics_variables.beta limit. Does nothing atm so commented out - # call stblim(physics_variables.beta_max) + # call stblim(physics_variables.beta_vol_avg_max) # Calculate the neoclassical sanity check with PROCESS parameters ( diff --git a/tests/regression/input_files/helias_5b.IN.DAT b/tests/regression/input_files/helias_5b.IN.DAT index 3c7fe69065..9042af4706 100644 --- a/tests/regression/input_files/helias_5b.IN.DAT +++ b/tests/regression/input_files/helias_5b.IN.DAT @@ -99,7 +99,7 @@ dz_xpoint_divertor = 0.0 *Vertical gap between x-point and divertor *---------------Constraint Variables---------------* p_plant_electric_net_required_mw = 1000 *Required net electric power (MW) -beta_max = 0.05 *upper beta limit +beta_vol_avg_max = 0.05 *upper beta limit beta_min = 0.01 *lower beta limit *-------------Current Drive Variables--------------* diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index d1492a003e..c89c308dc9 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -305,7 +305,7 @@ icc = 24 * JUSTIFICATION: Limit for plasma stability * VARIABLES: beta calculated in-situ -*beta_max +*beta_vol_avg_max * DESCRIPTION: Plasma beta upper limit * JUSTIFICATION: Turned off, not in use. icc=24. Allow to be calculated in-situ diff --git a/tests/regression/input_files/stellarator_helias_eval.IN.DAT b/tests/regression/input_files/stellarator_helias_eval.IN.DAT index 07b18d7169..0086eac52d 100644 --- a/tests/regression/input_files/stellarator_helias_eval.IN.DAT +++ b/tests/regression/input_files/stellarator_helias_eval.IN.DAT @@ -259,7 +259,7 @@ zref(10) = 1.0 alphan = 0.35 * density profile index alphat = 1.2 * temperature profile index aspect = 10.1 * aspect ratio (`iteration variable 1`) -beta_max = 0.06 * Max allowable beta +beta_vol_avg_max = 0.06 * Max allowable beta beta_min = 0.01 * allowable lower beta b_plasma_toroidal_on_axis = 4.734563638052739 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 1.631669195728548e+20 * electron density (/m3) (`iteration variable 6`) From 41faba43381dd772e391c136da0ab0c0c485f393 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:37:06 +0100 Subject: [PATCH 23/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`beta=5Fmin`=20to?= =?UTF-8?q?=20`beta=5Fvol=5Favg=5Fmin`=20across=20multiple=20files=20for?= =?UTF-8?q?=20clarity=20and=20consistency=20in=20plasma=20beta=20calculati?= =?UTF-8?q?ons.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../physics-models/plasma_beta/plasma_beta.md | 2 +- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/constraints.py | 8 ++++---- process/data_structure/numerics.py | 2 +- process/data_structure/physics_variables.py | 8 ++++---- process/input.py | 2 +- process/io/obsolete_vars.py | 2 +- process/physics.py | 12 ++++++------ tests/regression/input_files/helias_5b.IN.DAT | 2 +- tests/regression/input_files/st_regression.IN.DAT | 4 ++-- .../input_files/stellarator_helias_eval.IN.DAT | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/documentation/physics-models/plasma_beta/plasma_beta.md b/documentation/physics-models/plasma_beta/plasma_beta.md index 28872a7355..52c3441fed 100644 --- a/documentation/physics-models/plasma_beta/plasma_beta.md +++ b/documentation/physics-models/plasma_beta/plasma_beta.md @@ -433,7 +433,7 @@ The value of `beta_poloidal_max` can be set to the desired maximum poloidal beta This constraint can be activated by stating `icc = 84` in the input file. -The value of `beta_min` can be set to the desired minimum total beta. The scaling value `fbeta_min` can be varied also. +The value of `beta_vol_avg_min` can be set to the desired minimum total beta. The scaling value `fbeta_min` can be varied also. [^0]: F. Troyon et.al, “Beta limit in tokamaks. Experimental and computational status,” Plasma Physics and Controlled Fusion, vol. 30, no. 11, pp. 1597–1609, Oct. 1988, doi: https://doi.org/10.1088/0741-3335/30/11/019. diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index fd2f52dcd9..f3fa1de000 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -203,7 +203,7 @@ Cylindrical_safety_factor_(qcyl)_________________________________________ (qstar)________________________ 4.12802018540024562e+00 OP Upper_limit_on_thermal_beta______________________________________________ (beta_vol_avg_max_avg_max)_____________________ 6.75897673577628422e-02 OP Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 3.23040881535548857e-02 - Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP + Lower_limit_on_thermal_beta______________________________________________ (beta_vol_avg_min_avg_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal_vol_avg)________________ 1.32822381700080405e+00 OP Total_toroidal_beta______________________________________________________ (beta_toroidal_vol_avg)________________ 3.31093495352616854e-02 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index cfb3df6431..8701d09ae7 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -275,7 +275,7 @@ Cylindrical_safety_factor_(qcyl)_________________________________________ (qstar)________________________ 3.37999298978303386e+00 OP Upper_limit_on_thermal_beta______________________________________________ (beta_vol_avg_max_avg_max)_____________________ 7.35303866910386600e-02 OP Total_plasma_beta________________________________________________________ (beta_total_vol_avg)_________________________ 4.48303922556954615e-02 - Lower_limit_on_thermal_beta______________________________________________ (beta_min)_____________________ 0.00000000000000000e+00 IP + Lower_limit_on_thermal_beta______________________________________________ (beta_vol_avg_min)_____________________ 0.00000000000000000e+00 IP Upper_limit_on_poloidal_beta_____________________________________________ (beta_poloidal_max)____________ 1.90000000000000002e-01 IP Total_poloidal_beta______________________________________________________ (beta_poloidal)________________ 1.25053557633615986e+00 OP Total_toroidal_beta______________________________________________________ (beta_toroidal_vol_avg)________________ 4.64972707732098992e-02 OP diff --git a/process/constraints.py b/process/constraints.py index e890cb384e..14dd41ea72 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -2149,19 +2149,19 @@ def constraint_equation_84(): """Equation for the lower limit of beta author: J Lion, IPP Greifswald - fbeta_min: f-value for constraint beta-beta_fast_alpha > beta_min - beta_min: Lower limit for beta + fbeta_min: f-value for constraint beta-beta_fast_alpha > beta_vol_avg_min + beta_vol_avg_min: Lower limit for beta beta: plasma beta """ cc = ( 1.0 - data_structure.constraint_variables.fbeta_min * data_structure.physics_variables.beta_total_vol_avg - / data_structure.physics_variables.beta_min + / data_structure.physics_variables.beta_vol_avg_min ) return ConstraintResult( cc, - data_structure.physics_variables.beta_min * (1.0 - cc), + data_structure.physics_variables.beta_vol_avg_min * (1.0 - cc), data_structure.physics_variables.beta_total_vol_avg * cc, ) diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index b948f77e1a..03da0eb174 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -612,7 +612,7 @@ def init_numerics(): "nd_plasma_electron_on_axis > nd_plasma_pedestal_electron ", "toroidalgap > dx_tf_inboard_out_t", "available_space > required_space ", - "beta > beta_min ", + "beta > beta_vol_avg_min ", "CP lifetime ", "TFC turn dimension ", "Cryogenic plant power ", diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index b8cdcb22da..dbc4220443 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -225,8 +225,8 @@ """Max allowable volume averaged beta""" -beta_min: float = None -"""allowable lower beta""" +beta_vol_avg_min: float = None +"""Minimum allowable volume averaged beta""" beta_beam: float = None @@ -1378,7 +1378,7 @@ def init_physics_variables(): global beta_total_vol_avg global beta_fast_alpha global beta_vol_avg_max - global beta_min + global beta_vol_avg_min global beta_beam global beta_poloidal_vol_avg global beta_poloidal_eps @@ -1631,7 +1631,7 @@ def init_physics_variables(): beta_total_vol_avg = 0.042 beta_fast_alpha = 0.0 beta_vol_avg_max = 0.0 - beta_min = 0.0 + beta_vol_avg_min = 0.0 beta_beam = 0.0 beta_poloidal_vol_avg = 0.0 beta_poloidal_eps = 0.0 diff --git a/process/input.py b/process/input.py index 06292bdb5f..12994f3ddb 100644 --- a/process/input.py +++ b/process/input.py @@ -122,7 +122,7 @@ def __post_init__(self): "beta_vol_avg_max": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), - "beta_min": InputVariable( + "beta_vol_avg_min": InputVariable( data_structure.physics_variables, float, range=(0.0, 1.0) ), "betbm0": InputVariable(data_structure.physics_variables, float, range=(0.0, 10.0)), diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index bb7e7e839d..950cb9f05c 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -152,7 +152,7 @@ "dnbeta": "beta_norm_max", "ifalphap": "i_beta_fast_alpha", "betalim": "beta_vol_avg_max", - "betalim_lower": "beta_min", + "betalim_lower": "beta_vol_avg_min", "fbeta": "fbeta_poloidal_eps", "fcwr": "fr_conducting_wall", "cvol": "f_vol_plasma", diff --git a/process/physics.py b/process/physics.py index 25e1bff9b1..e8480cfd28 100644 --- a/process/physics.py +++ b/process/physics.py @@ -4352,24 +4352,24 @@ def outplas(self): po.ovarrf( self.outfile, "Lower limit on total beta", - "(beta_min)", - physics_variables.beta_min, + "(beta_vol_avg_min)", + physics_variables.beta_vol_avg_min, "IP", ) elif physics_variables.i_beta_component == 1: po.ovarrf( self.outfile, "Lower limit on thermal beta", - "(beta_min)", - physics_variables.beta_min, + "(beta_vol_avg_min)", + physics_variables.beta_vol_avg_min, "IP", ) else: po.ovarrf( self.outfile, "Lower limit on thermal + NB beta", - "(beta_min)", - physics_variables.beta_min, + "(beta_vol_avg_min)", + physics_variables.beta_vol_avg_min, "IP", ) po.ovarre( diff --git a/tests/regression/input_files/helias_5b.IN.DAT b/tests/regression/input_files/helias_5b.IN.DAT index 9042af4706..afd0348cdc 100644 --- a/tests/regression/input_files/helias_5b.IN.DAT +++ b/tests/regression/input_files/helias_5b.IN.DAT @@ -100,7 +100,7 @@ dz_xpoint_divertor = 0.0 *Vertical gap between x-point and divertor p_plant_electric_net_required_mw = 1000 *Required net electric power (MW) beta_vol_avg_max = 0.05 *upper beta limit -beta_min = 0.01 *lower beta limit +beta_vol_avg_min = 0.01 *lower beta limit *-------------Current Drive Variables--------------* diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index c89c308dc9..afcdc453e7 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -349,9 +349,9 @@ i_beta_norm_max = 0 *icc = 84 * DESCRIPTION: Constraint equation for lower limit of beta * JUSTIFICATION: Turned off, do not require a beta lower limit -* VARIABLES: beta_min (Lower limit for beta). beta,betaft calculated in-situ +* VARIABLES: beta_vol_avg_min (Lower limit for beta). beta,betaft calculated in-situ -*beta_min = +*beta_vol_avg_min = * DESCRIPTION: Plasma beta lower limit * JUSTIFICATION: Turned off, not in use, Used with icc=84 to enforce beta limit diff --git a/tests/regression/input_files/stellarator_helias_eval.IN.DAT b/tests/regression/input_files/stellarator_helias_eval.IN.DAT index 0086eac52d..f9f0637740 100644 --- a/tests/regression/input_files/stellarator_helias_eval.IN.DAT +++ b/tests/regression/input_files/stellarator_helias_eval.IN.DAT @@ -260,7 +260,7 @@ alphan = 0.35 * density profile index alphat = 1.2 * temperature profile index aspect = 10.1 * aspect ratio (`iteration variable 1`) beta_vol_avg_max = 0.06 * Max allowable beta -beta_min = 0.01 * allowable lower beta +beta_vol_avg_min = 0.01 * allowable lower beta b_plasma_toroidal_on_axis = 4.734563638052739 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 1.631669195728548e+20 * electron density (/m3) (`iteration variable 6`) f_p_alpha_plasma_deposited = 0.95 * Fraction of alpha power deposited in plasma; Default of 0;95 taken from https;//doi;org/10;1088/0029-5515/39/12/305; From afbd442e20c9dd562e5cdabbae3582439fab940d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:40:38 +0100 Subject: [PATCH 24/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`beta=5Fthermal?= =?UTF-8?q?=5Fpoloidal`=20to=20`beta=5Fthermal=5Fpoloidal=5Fvol=5Favg`=20a?= =?UTF-8?q?cross=20multiple=20files=20for=20clarity=20and=20consistency=20?= =?UTF-8?q?in=20plasma=20beta=20calculations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 8 ++++---- process/io/plot_proc.py | 2 +- process/physics.py | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index f3fa1de000..5eeb361fee 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -211,7 +211,7 @@ Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.54271719682202629e-01 OP Thermal_beta_____________________________________________________________ (beta_thermal_vol_avg)_________________ 2.79865542945546136e-02 OP - Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal)________ 1.15070290153733867e+00 OP + Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal_vol_avg)________ 1.15070290153733867e+00 OP Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 2.86841901873654617e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.42741272333601332e-01 OP Poloidal_beta_and_inverse_aspect_ratio_upper_limit_______________________ (beta_poloidal_eps_max)________ 1.37999999999999989e+00 diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 8701d09ae7..b9f9444fd8 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -283,7 +283,7 @@ Neutral_Beam_ion_beta____________________________________________________ (beta_beam)____________________ 0.00000000000000000e+00 OP Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.35301246588149487e-01 OP Thermal_beta_____________________________________________________________ (beta_thermal_vol_avg)_________________ 3.94876623190729900e-02 OP - Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal)________ 1.10150110386500244e+00 OP + Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal_vol_avg_vol_avg)________ 1.10150110386500244e+00 OP Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 4.09558880631420777e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.16845192112053287e-01 OP Poloidal_beta_and_inverse_aspect_ratio_upper_limit_______________________ (beta_poloidal_eps_max)________ 1.37999999999999989e+00 diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index dbc4220443..ae37c9acc9 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -249,8 +249,8 @@ """Plasma volume averaged thermal beta""" -beta_thermal_poloidal: float = None -"""poloidal thermal beta""" +beta_thermal_poloidal_vol_avg: float = None +"""Plasma volume averaged poloidal thermal beta""" beta_thermal_toroidal: float = None @@ -1384,7 +1384,7 @@ def init_physics_variables(): global beta_poloidal_eps global beta_toroidal_vol_avg global beta_thermal_vol_avg - global beta_thermal_poloidal + global beta_thermal_poloidal_vol_avg global beta_thermal_toroidal global beta_norm_total global beta_norm_thermal @@ -1637,7 +1637,7 @@ def init_physics_variables(): beta_poloidal_eps = 0.0 beta_toroidal_vol_avg = 0.0 beta_thermal_vol_avg = 0.0 - beta_thermal_poloidal = 0.0 + beta_thermal_poloidal_vol_avg = 0.0 beta_thermal_toroidal = 0.0 beta_norm_total = 0.0 beta_norm_thermal = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 5ffe61ffc7..80633bf585 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -6869,7 +6869,7 @@ def plot_physics_info(axis, mfile_data, scan): ("q95", r"$q_{\mathrm{95}}$", ""), ("beta_norm_thermal", r"$\beta_N$, thermal", "% m T MA$^{-1}$"), ("beta_norm_toroidal", r"$\beta_N$, toroidal", "% m T MA$^{-1}$"), - ("beta_thermal_poloidal", r"$\beta_P$, thermal", ""), + ("beta_thermal_poloidal_vol_avg", r"$\beta_P$, thermal", ""), ("beta_poloidal", r"$\beta_P$, total", ""), ("te", r"$\langle T_e \rangle$", "keV"), ("nd_plasma_electrons_vol_avg", r"$\langle n_e \rangle$", "m$^{-3}$"), diff --git a/process/physics.py b/process/physics.py index e8480cfd28..65b6a5aa69 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1764,7 +1764,7 @@ def physics(self): physics_variables.beta_poloidal_vol_avg * physics_variables.eps ) - physics_variables.beta_thermal_poloidal = ( + physics_variables.beta_thermal_poloidal_vol_avg = ( physics_variables.beta_thermal_vol_avg * ( physics_variables.b_plasma_total @@ -1972,7 +1972,7 @@ def physics(self): physics_variables.alphaj, physics_variables.alphap, physics_variables.alphat, - physics_variables.beta_thermal_poloidal, + physics_variables.beta_thermal_poloidal_vol_avg, physics_variables.q0, physics_variables.q95, physics_variables.rmajor, @@ -4425,8 +4425,8 @@ def outplas(self): po.ovarre( self.outfile, "Thermal poloidal beta", - "(beta_thermal_poloidal)", - physics_variables.beta_thermal_poloidal, + "(beta_thermal_poloidal_vol_avg)", + physics_variables.beta_thermal_poloidal_vol_avg, "OP ", ) po.ovarre( From 56853c6362119c713855c218b7a4e024d6a9b252 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:43:32 +0100 Subject: [PATCH 25/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`beta=5Fthermal?= =?UTF-8?q?=5Ftoroidal`=20to=20`beta=5Fthermal=5Ftoroidal=5Fvol=5Favg`=20a?= =?UTF-8?q?cross=20multiple=20files=20for=20clarity=20and=20consistency=20?= =?UTF-8?q?in=20plasma=20beta=20calculations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 2 +- process/data_structure/physics_variables.py | 8 ++++---- process/physics.py | 6 +++--- tests/integration/data/large_tokamak_MFILE.DAT | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 5eeb361fee..c3b01264ce 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -212,7 +212,7 @@ Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.54271719682202629e-01 OP Thermal_beta_____________________________________________________________ (beta_thermal_vol_avg)_________________ 2.79865542945546136e-02 OP Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal_vol_avg)________ 1.15070290153733867e+00 OP - Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 2.86841901873654617e-02 OP + Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal_vol_avg)________ 2.86841901873654617e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.42741272333601332e-01 OP Poloidal_beta_and_inverse_aspect_ratio_upper_limit_______________________ (beta_poloidal_eps_max)________ 1.37999999999999989e+00 Beta_g_coefficient_______________________________________________________ (beta_norm_max)________________ 5.95715248137752251e+00 OP diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index b9f9444fd8..1ebdf14483 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -284,7 +284,7 @@ Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.35301246588149487e-01 OP Thermal_beta_____________________________________________________________ (beta_thermal_vol_avg)_________________ 3.94876623190729900e-02 OP Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal_vol_avg_vol_avg)________ 1.10150110386500244e+00 OP - Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 4.09558880631420777e-02 OP + Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal_vol_avg)________ 4.09558880631420777e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.16845192112053287e-01 OP Poloidal_beta_and_inverse_aspect_ratio_upper_limit_______________________ (beta_poloidal_eps_max)________ 1.37999999999999989e+00 Beta_g_coefficient_______________________________________________________ (beta_norm_max)________________ 5.30638311255202044e+00 OP diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index ae37c9acc9..8c355951f4 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -253,8 +253,8 @@ """Plasma volume averaged poloidal thermal beta""" -beta_thermal_toroidal: float = None -"""poloidal thermal beta""" +beta_thermal_toroidal_vol_avg: float = None +"""Plasma volume averaged toloidal thermal beta""" beta_norm_total: float = None @@ -1385,7 +1385,7 @@ def init_physics_variables(): global beta_toroidal_vol_avg global beta_thermal_vol_avg global beta_thermal_poloidal_vol_avg - global beta_thermal_toroidal + global beta_thermal_toroidal_vol_avg global beta_norm_total global beta_norm_thermal global beta_norm_poloidal @@ -1638,7 +1638,7 @@ def init_physics_variables(): beta_toroidal_vol_avg = 0.0 beta_thermal_vol_avg = 0.0 beta_thermal_poloidal_vol_avg = 0.0 - beta_thermal_toroidal = 0.0 + beta_thermal_toroidal_vol_avg = 0.0 beta_norm_total = 0.0 beta_norm_thermal = 0.0 beta_norm_poloidal = 0.0 diff --git a/process/physics.py b/process/physics.py index 65b6a5aa69..78a304a04c 100644 --- a/process/physics.py +++ b/process/physics.py @@ -1772,7 +1772,7 @@ def physics(self): ) ** 2 ) - physics_variables.beta_thermal_toroidal = ( + physics_variables.beta_thermal_toroidal_vol_avg = ( physics_variables.beta_thermal_vol_avg * ( physics_variables.b_plasma_total @@ -4432,8 +4432,8 @@ def outplas(self): po.ovarre( self.outfile, "Thermal toroidal beta", - "(beta_thermal_toroidal)", - physics_variables.beta_thermal_toroidal, + "(beta_thermal_toroidal_vol_avg)", + physics_variables.beta_thermal_toroidal_vol_avg, "OP ", ) diff --git a/tests/integration/data/large_tokamak_MFILE.DAT b/tests/integration/data/large_tokamak_MFILE.DAT index b7690d47c7..71c4d5aadd 100644 --- a/tests/integration/data/large_tokamak_MFILE.DAT +++ b/tests/integration/data/large_tokamak_MFILE.DAT @@ -440,7 +440,7 @@ Ratio_of_fast_alpha_and_beam_beta_to_thermal_beta________________________ (f_beta_alpha_beam_thermal)____ 1.46364988526139467e-01 OP Thermal_beta_____________________________________________________________ (beta_thermal)_________________ 2.77905942536692679e-02 OP Thermal_poloidal_beta____________________________________________________ (beta_thermal_poloidal)________ 1.15531987757017807e+00 OP - Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal)________ 2.84755583964189651e-02 OP + Thermal_toroidal_beta____________________________________________________ (beta_thermal_toroidal_vol_avg)________ 2.84755583964189651e-02 OP Poloidal_beta_and_inverse_aspect_ratio___________________________________ (beta_poloidal_eps)____________ 4.41472752731586038e-01 OP Poloidal_beta_and_inverse_aspect_ratio_upper_limit_______________________ (beta_poloidal_eps_max)________ 1.37999999999999989e+00 Beta_g_coefficient_______________________________________________________ (beta_norm_max)________________ 3.60000000000000009e+00 OP From f5a6ea91a218812093cb693c5a3b52ffb13da2af Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 16:56:03 +0100 Subject: [PATCH 26/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`dlimit`=20to=20`?= =?UTF-8?q?nd=5Fplasma=5Felectron=5Fmax=5Farray`=20across=20multiple=20fil?= =?UTF-8?q?es=20for=20clarity=20and=20consistency=20in=20plasma=20density?= =?UTF-8?q?=20limit=20calculations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/csv_output_large_tokamak_MFILE.DAT | 14 ++-- examples/data/large_tokamak_1_MFILE.DAT | 14 ++-- examples/data/large_tokamak_2_MFILE.DAT | 14 ++-- examples/data/large_tokamak_3_MFILE.DAT | 14 ++-- examples/data/large_tokamak_4_MFILE.DAT | 14 ++-- examples/data/large_tokamak_nof_2_MFILE.DAT | 16 ++-- examples/data/large_tokamak_nof_MFILE.DAT | 16 ++-- process/constraints.py | 4 +- process/data_structure/physics_variables.py | 8 +- process/io/plot_proc.py | 22 ++--- process/physics.py | 83 ++++++++++--------- process/stellarator.py | 8 +- tests/unit/test_physics.py | 6 +- tests/unit/test_stellarator.py | 4 +- 14 files changed, 125 insertions(+), 112 deletions(-) diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index fb6e97eb71..c05d16abd1 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -406,13 +406,13 @@ Electron_density_at_separatrix_/_nGW____________________________________ (fgwsep_out)__________________ 5.0000E-01 Temperature_profile_index_______________________________________________ (alphat)______________________ 1.4500E+00 Temperature_profile_index_beta__________________________________________ (tbeta)_______________________ 2.0000E+00 - Old_ASDEX_model_________________________________________________________ (dlimit(1))___________________ 5.2107E+19 OP - Borrass_ITER_model_I____________________________________________________ (dlimit(2))___________________ 1.0653E+20 OP - Borrass_ITER_model_II___________________________________________________ (dlimit(3))___________________ 4.1967E+19 OP - JET_edge_radiation_model________________________________________________ (dlimit(4))___________________ 3.0404E+21 OP - JET_simplified_model____________________________________________________ (dlimit(5))___________________ 4.0490E+20 OP - Hugill-Murakami_Mq_model________________________________________________ (dlimit(6))___________________ 6.6879E+19 OP - Greenwald_model_________________________________________________________ (dlimit(7))___________________ 7.4748E+19 OP + Old_ASDEX_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(1))___________________ 5.2107E+19 OP + Borrass_ITER_model_I____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(2))___________________ 1.0653E+20 OP + Borrass_ITER_model_II___________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(3))___________________ 4.1967E+19 OP + JET_edge_radiation_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(4))___________________ 3.0404E+21 OP + JET_simplified_model____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(5))___________________ 4.0490E+20 OP + Hugill-Murakami_Mq_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))___________________ 6.6879E+19 OP + Greenwald_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))___________________ 7.4748E+19 OP Deuterium_fuel_fraction_________________________________________________ (fdeut)_______________________ 5.0000E-01 Tritium_fuel_fraction___________________________________________________ (ftrit)_______________________ 5.0000E-01 Total_fusion_power_(MW)_________________________________________________ (p_fusion_total_mw)______________________ 1.5926E+03 OP diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index 523871ed37..2efdf7c5f1 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -407,13 +407,13 @@ Electron_density_at_separatrix_/_nGW____________________________________ (fgwsep_out)__________________ 5.0000E-01 Temperature_profile_index_______________________________________________ (alphat)______________________ 1.4500E+00 Temperature_profile_index_beta__________________________________________ (tbeta)_______________________ 2.0000E+00 - Old_ASDEX_model_________________________________________________________ (dlimit(1))___________________ 5.2797E+19 OP - Borrass_ITER_model_I____________________________________________________ (dlimit(2))___________________ 1.0969E+20 OP - Borrass_ITER_model_II___________________________________________________ (dlimit(3))___________________ 4.3575E+19 OP - JET_edge_radiation_model________________________________________________ (dlimit(4))___________________ 3.0227E+21 OP - JET_simplified_model____________________________________________________ (dlimit(5))___________________ 4.3397E+20 OP - Hugill-Murakami_Mq_model________________________________________________ (dlimit(6))___________________ 6.6609E+19 OP - Greenwald_model_________________________________________________________ (dlimit(7))___________________ 7.4445E+19 OP + Old_ASDEX_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(1))___________________ 5.2797E+19 OP + Borrass_ITER_model_I____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(2))___________________ 1.0969E+20 OP + Borrass_ITER_model_II___________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(3))___________________ 4.3575E+19 OP + JET_edge_radiation_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(4))___________________ 3.0227E+21 OP + JET_simplified_model____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(5))___________________ 4.3397E+20 OP + Hugill-Murakami_Mq_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))___________________ 6.6609E+19 OP + Greenwald_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))___________________ 7.4445E+19 OP Deuterium_fuel_fraction_________________________________________________ (fdeut)_______________________ 5.0000E-01 Tritium_fuel_fraction___________________________________________________ (ftrit)_______________________ 5.0000E-01 Total_fusion_power_(MW)_________________________________________________ (p_fusion_total_mw)______________________ 1.6202E+03 OP diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index e8d1a4296e..3618baa185 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -407,13 +407,13 @@ Electron_density_at_separatrix_/_nGW____________________________________ (fgwsep_out)__________________ 5.0000E-01 Temperature_profile_index_______________________________________________ (alphat)______________________ 1.4500E+00 Temperature_profile_index_beta__________________________________________ (tbeta)_______________________ 2.0000E+00 - Old_ASDEX_model_________________________________________________________ (dlimit(1))___________________ 5.2797E+19 OP - Borrass_ITER_model_I____________________________________________________ (dlimit(2))___________________ 1.0969E+20 OP - Borrass_ITER_model_II___________________________________________________ (dlimit(3))___________________ 4.3575E+19 OP - JET_edge_radiation_model________________________________________________ (dlimit(4))___________________ 3.0227E+21 OP - JET_simplified_model____________________________________________________ (dlimit(5))___________________ 4.3397E+20 OP - Hugill-Murakami_Mq_model________________________________________________ (dlimit(6))___________________ 6.6609E+19 OP - Greenwald_model_________________________________________________________ (dlimit(7))___________________ 7.4445E+19 OP + Old_ASDEX_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(1))___________________ 5.2797E+19 OP + Borrass_ITER_model_I____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(2))___________________ 1.0969E+20 OP + Borrass_ITER_model_II___________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(3))___________________ 4.3575E+19 OP + JET_edge_radiation_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(4))___________________ 3.0227E+21 OP + JET_simplified_model____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(5))___________________ 4.3397E+20 OP + Hugill-Murakami_Mq_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))___________________ 6.6609E+19 OP + Greenwald_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))___________________ 7.4445E+19 OP Deuterium_fuel_fraction_________________________________________________ (fdeut)_______________________ 5.0000E-01 Tritium_fuel_fraction___________________________________________________ (ftrit)_______________________ 5.0000E-01 Total_fusion_power_(MW)_________________________________________________ (p_fusion_total_mw)______________________ 1.6202E+03 OP diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 9a525f234d..946d276ca1 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -407,13 +407,13 @@ Electron_density_at_separatrix_/_nGW____________________________________ (fgwsep_out)__________________ 5.0000E-01 Temperature_profile_index_______________________________________________ (alphat)______________________ 1.4500E+00 Temperature_profile_index_beta__________________________________________ (tbeta)_______________________ 2.0000E+00 - Old_ASDEX_model_________________________________________________________ (dlimit(1))___________________ 5.2797E+19 OP - Borrass_ITER_model_I____________________________________________________ (dlimit(2))___________________ 1.0969E+20 OP - Borrass_ITER_model_II___________________________________________________ (dlimit(3))___________________ 4.3575E+19 OP - JET_edge_radiation_model________________________________________________ (dlimit(4))___________________ 3.0227E+21 OP - JET_simplified_model____________________________________________________ (dlimit(5))___________________ 4.3397E+20 OP - Hugill-Murakami_Mq_model________________________________________________ (dlimit(6))___________________ 6.6609E+19 OP - Greenwald_model_________________________________________________________ (dlimit(7))___________________ 7.4445E+19 OP + Old_ASDEX_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(1))___________________ 5.2797E+19 OP + Borrass_ITER_model_I____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(2))___________________ 1.0969E+20 OP + Borrass_ITER_model_II___________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(3))___________________ 4.3575E+19 OP + JET_edge_radiation_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(4))___________________ 3.0227E+21 OP + JET_simplified_model____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(5))___________________ 4.3397E+20 OP + Hugill-Murakami_Mq_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))___________________ 6.6609E+19 OP + Greenwald_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))___________________ 7.4445E+19 OP Deuterium_fuel_fraction_________________________________________________ (fdeut)_______________________ 5.0000E-01 Tritium_fuel_fraction___________________________________________________ (ftrit)_______________________ 5.0000E-01 Total_fusion_power_(MW)_________________________________________________ (p_fusion_total_mw)______________________ 1.6202E+03 OP diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index ed47282e69..3e172276fb 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -407,13 +407,13 @@ Electron_density_at_separatrix_/_nGW____________________________________ (fgwsep_out)__________________ 5.0000E-01 Temperature_profile_index_______________________________________________ (alphat)______________________ 1.4500E+00 Temperature_profile_index_beta__________________________________________ (tbeta)_______________________ 2.0000E+00 - Old_ASDEX_model_________________________________________________________ (dlimit(1))___________________ 5.2797E+19 OP - Borrass_ITER_model_I____________________________________________________ (dlimit(2))___________________ 1.0969E+20 OP - Borrass_ITER_model_II___________________________________________________ (dlimit(3))___________________ 4.3575E+19 OP - JET_edge_radiation_model________________________________________________ (dlimit(4))___________________ 3.0227E+21 OP - JET_simplified_model____________________________________________________ (dlimit(5))___________________ 4.3397E+20 OP - Hugill-Murakami_Mq_model________________________________________________ (dlimit(6))___________________ 6.6609E+19 OP - Greenwald_model_________________________________________________________ (dlimit(7))___________________ 7.4445E+19 OP + Old_ASDEX_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(1))___________________ 5.2797E+19 OP + Borrass_ITER_model_I____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(2))___________________ 1.0969E+20 OP + Borrass_ITER_model_II___________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(3))___________________ 4.3575E+19 OP + JET_edge_radiation_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(4))___________________ 3.0227E+21 OP + JET_simplified_model____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(5))___________________ 4.3397E+20 OP + Hugill-Murakami_Mq_model________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))___________________ 6.6609E+19 OP + Greenwald_model_________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))___________________ 7.4445E+19 OP Deuterium_fuel_fraction_________________________________________________ (fdeut)_______________________ 5.0000E-01 Tritium_fuel_fraction___________________________________________________ (ftrit)_______________________ 5.0000E-01 Total_fusion_power_(MW)_________________________________________________ (p_fusion_total_mw)______________________ 1.6202E+03 OP diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index c3b01264ce..29f6fa469c 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -275,14 +275,14 @@ Temperature_profile_index________________________________________________ (alphat)_______________________ 1.44999999999999996e+00 Temperature_profile_index_beta___________________________________________ (tbeta)________________________ 2.00000000000000000e+00 Pressure_profile_index___________________________________________________ (alphap)_______________________ 2.45000000000000018e+00 - Old_ASDEX_model__________________________________________________________ (dlimit(1))____________________ 2.90898762676047462e+19 OP - Borrass_ITER_model_I_____________________________________________________ (dlimit(2))____________________ 5.32771894980833526e+19 OP - Borrass_ITER_model_II____________________________________________________ (dlimit(3))____________________ 2.01519696896069632e+19 OP - JET_edge_radiation_model_________________________________________________ (dlimit(4))____________________ 1.71437007414591567e+21 OP - JET_simplified_model_____________________________________________________ (dlimit(5))____________________ 2.21998796377134301e+20 OP - Hugill-Murakami_Mq_model_________________________________________________ (dlimit(6))____________________ 4.83130102547807273e+19 OP - Greenwald_model__________________________________________________________ (dlimit(7))____________________ 7.20274886424344904e+19 OP - ASDEX_New________________________________________________________________ (dlimit(8))____________________ 8.37005006999513989e+20 OP + Old_ASDEX_model__________________________________________________________ (nd_plasma_electron_max_array(1))____________________ 2.90898762676047462e+19 OP + Borrass_ITER_model_I_____________________________________________________ (nd_plasma_electron_max_array(2))____________________ 5.32771894980833526e+19 OP + Borrass_ITER_model_II____________________________________________________ (nd_plasma_electron_max_array(3))____________________ 2.01519696896069632e+19 OP + JET_edge_radiation_model_________________________________________________ (nd_plasma_electron_max_array(4))____________________ 1.71437007414591567e+21 OP + JET_simplified_model_____________________________________________________ (nd_plasma_electron_max_array(5))____________________ 2.21998796377134301e+20 OP + Hugill-Murakami_Mq_model_________________________________________________ (nd_plasma_electron_max_array(6))____________________ 4.83130102547807273e+19 OP + Greenwald_model__________________________________________________________ (nd_plasma_electron_max_array(7))____________________ 7.20274886424344904e+19 OP + ASDEX_New________________________________________________________________ (nd_plasma_electron_max_array(8))____________________ 8.37005006999513989e+20 OP Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.20274886424344904e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 1ebdf14483..33c0e0efbd 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -347,14 +347,14 @@ Temperature_profile_index________________________________________________ (alphat)_______________________ 1.44999999999999996e+00 Temperature_profile_index_beta___________________________________________ (tbeta)________________________ 2.00000000000000000e+00 Pressure_profile_index___________________________________________________ (alphap)_______________________ 2.45000000000000018e+00 - Old_ASDEX_model__________________________________________________________ (dlimit(1))____________________ 5.04927402258230395e+19 OP - Borrass_ITER_model_I_____________________________________________________ (dlimit(2))____________________ 9.91154917220369859e+19 OP - Borrass_ITER_model_II____________________________________________________ (dlimit(3))____________________ 3.82528337286505349e+19 OP - JET_edge_radiation_model_________________________________________________ (dlimit(4))____________________ 2.02644839996092947e+21 OP - JET_simplified_model_____________________________________________________ (dlimit(5))____________________ 3.52789232059618492e+20 OP - Hugill-Murakami_Mq_model_________________________________________________ (dlimit(6))____________________ 5.26219719824596337e+19 OP - Greenwald_model__________________________________________________________ (dlimit(7))____________________ 7.84515075612383478e+19 OP - ASDEX_New________________________________________________________________ (dlimit(8))____________________ 1.03091554466307611e+21 OP + Old_ASDEX_model__________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(1))____________________ 5.04927402258230395e+19 OP + Borrass_ITER_model_I_____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(2))____________________ 9.91154917220369859e+19 OP + Borrass_ITER_model_II____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(3))____________________ 3.82528337286505349e+19 OP + JET_edge_radiation_model_________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(4))____________________ 2.02644839996092947e+21 OP + JET_simplified_model_____________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(5))____________________ 3.52789232059618492e+20 OP + Hugill-Murakami_Mq_model_________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))____________________ 5.26219719824596337e+19 OP + Greenwald_model__________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))____________________ 7.84515075612383478e+19 OP + ASDEX_New________________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(8))____________________ 1.03091554466307611e+21 OP Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.84515075612383478e+19 OP Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*dnelimt)____________ 7.84515075612383478e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 diff --git a/process/constraints.py b/process/constraints.py index 14dd41ea72..ea870b37b0 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -1939,7 +1939,7 @@ def constraint_equation_76(): triang: plasma separatrix triangularity (calculated if i_plasma_geometry = 1, 3-5 or 7) aspect: aspect ratio (iteration variable 1) p_plasma_separatrix_mw: power to conducted to the divertor region (MW) - dlimit(7)array : density limit (/m3) as calculated using various models + nd_plasma_electron_max_array(7)array : density limit (/m3) as calculated using various models fnesep: f-value for Eich critical separatrix density """ # TODO: why on earth are these variables being set here!? Should they be local? @@ -1958,7 +1958,7 @@ def constraint_equation_76(): (data_structure.physics_variables.p_plasma_separatrix_mw * 1.0e6) ** (-11.0 / 70.0) ) - * data_structure.physics_variables.dlimit[6] + * data_structure.physics_variables.nd_plasma_electron_max_array[6] ) cc = ( diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 8c355951f4..2a401d81c7 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -342,8 +342,8 @@ """ion-electron coulomb logarithm""" -dlimit: list[float] = None -"""density limit (/m3) as calculated using various models""" +nd_plasma_electron_max_array: list[float] = None +"""Plasma electron density max limit model array (/m3)""" nd_plasma_alphas_vol_avg: float = None @@ -1407,7 +1407,7 @@ def init_physics_variables(): global nd_plasma_fuel_ions_vol_avg global dlamee global dlamie - global dlimit + global nd_plasma_electron_max_array global nd_plasma_alphas_vol_avg global nd_beam_ions global nd_beam_ions_out @@ -1660,7 +1660,7 @@ def init_physics_variables(): nd_plasma_fuel_ions_vol_avg = 0.0 dlamee = 0.0 dlamie = 0.0 - dlimit = np.zeros(8, dtype=np.float64) + nd_plasma_electron_max_array = np.zeros(8, dtype=np.float64) nd_plasma_alphas_vol_avg = 0.0 nd_beam_ions = 0.0 nd_beam_ions_out = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 80633bf585..f36aea42cc 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3658,7 +3658,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): f"{ne0 / nd_plasma_electrons_vol_avg:.3f}", rf"$\rho_{{\text{{ped,n}}}}$: {radius_plasma_pedestal_density_norm:.3f}" r"$ \hspace{8} \frac{\overline{n_{e}}}{n_{\text{GW}}}$: " - f"{mfile_data.data['nd_plasma_electron_line'].get_scan(scan) / mfile_data.data['dlimit(7)'].get_scan(scan):.3f}", + f"{mfile_data.data['nd_plasma_electron_line'].get_scan(scan) / mfile_data.data['nd_plasma_electron_max_array(7)'].get_scan(scan):.3f}", rf"$n_{{\text{{e,sep}}}}$: {nd_plasma_separatrix_electron:.3e} m$^{{-3}}$", rf"$f_{{\text{{GW e,sep}}}}$: {fgwsep_out:.3f}", )) @@ -6839,7 +6839,7 @@ def plot_physics_info(axis, mfile_data, scan): axis.set_autoscalex_on(False) nong = mfile_data.data["nd_plasma_electron_line"].get_scan(scan) / mfile_data.data[ - "dlimit(7)" + "nd_plasma_electron_max_array(7)" ].get_scan(scan) nd_plasma_impurities_vol_avg = mfile_data.data[ @@ -8384,14 +8384,16 @@ def plot_density_limit_comparison( mfile_data (mf.MFile): MFILE data object. scan (int): Scan number to use. """ - old_asdex = mfile_data.data["dlimit(1)"].get_scan(scan) - borrass_iter_i = mfile_data.data["dlimit(2)"].get_scan(scan) - borrass_iter_ii = mfile_data.data["dlimit(3)"].get_scan(scan) - jet_edge_radiation = mfile_data.data["dlimit(4)"].get_scan(scan) - jet_simplified = mfile_data.data["dlimit(5)"].get_scan(scan) - hugill_murakami = mfile_data.data["dlimit(6)"].get_scan(scan) - greenwald = mfile_data.data["dlimit(7)"].get_scan(scan) - asdex_new = mfile_data.data["dlimit(8)"].get_scan(scan) + old_asdex = mfile_data.data["nd_plasma_electron_max_array(1)"].get_scan(scan) + borrass_iter_i = mfile_data.data["nd_plasma_electron_max_array(2)"].get_scan(scan) + borrass_iter_ii = mfile_data.data["nd_plasma_electron_max_array(3)"].get_scan(scan) + jet_edge_radiation = mfile_data.data["nd_plasma_electron_max_array(4)"].get_scan( + scan + ) + jet_simplified = mfile_data.data["nd_plasma_electron_max_array(5)"].get_scan(scan) + hugill_murakami = mfile_data.data["nd_plasma_electron_max_array(6)"].get_scan(scan) + greenwald = mfile_data.data["nd_plasma_electron_max_array(7)"].get_scan(scan) + asdex_new = mfile_data.data["nd_plasma_electron_max_array(8)"].get_scan(scan) # Data for the box plot data = { diff --git a/process/physics.py b/process/physics.py index 78a304a04c..20fa583c22 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2085,7 +2085,7 @@ def physics(self): q0=physics_variables.q0, radius_plasma_pedestal_density_norm=physics_variables.radius_plasma_pedestal_density_norm, nd_plasma_pedestal_electron=physics_variables.nd_plasma_pedestal_electron, - n_greenwald=physics_variables.dlimit[6], + n_greenwald=physics_variables.nd_plasma_electron_max_array[6], temp_plasma_pedestal_kev=physics_variables.temp_plasma_pedestal_kev, ) ) @@ -2459,7 +2459,7 @@ def physics(self): # Density limit ( - physics_variables.dlimit, + physics_variables.nd_plasma_electron_max_array, physics_variables.dnelimt, ) = self.calculate_density_limit( physics_variables.b_plasma_toroidal_on_axis, @@ -2805,7 +2805,7 @@ def physics(self): ), ) fgw = ( - physics_variables.dlimit[6] + physics_variables.nd_plasma_electron_max_array[6] / physics_variables.nd_plasma_electrons_vol_avg ) # calculate separatrix temperature, if Reinke criterion is used @@ -3074,7 +3074,7 @@ def calculate_density_limit( Returns: Tuple[np.ndarray, float]: A tuple containing: - - dlimit (np.ndarray): Average plasma density limit using seven different models (m^-3). + - nd_plasma_electron_max_array (np.ndarray): Average plasma density limit using seven different models (m^-3). - dnelimt (float): Enforced average plasma density limit (m^-3). Raises: @@ -3098,7 +3098,7 @@ def calculate_density_limit( "Illegal value for i_density_limit", i_density_limit=i_density_limit ) - dlimit = np.empty((8,)) + nd_plasma_electron_max_array = np.empty((8,)) # Power per unit area crossing the plasma edge # (excludes radiation and neutrons) @@ -3109,7 +3109,7 @@ def calculate_density_limit( # This applies to the density at the plasma edge, so must be scaled # to give the density limit applying to the average plasma density. - dlimit[0] = ( + nd_plasma_electron_max_array[0] = ( 1.54e20 * p_perp**0.43 * b_plasma_toroidal_on_axis**0.31 @@ -3121,7 +3121,7 @@ def calculate_density_limit( # to give the density limit applying to the average plasma density. # Borrass et al, ITER-TN-PH-9-6 (1989) - dlimit[1] = ( + nd_plasma_electron_max_array[1] = ( 1.8e20 * p_perp**0.53 * b_plasma_toroidal_on_axis**0.31 @@ -3134,7 +3134,7 @@ def calculate_density_limit( # This formula is (almost) identical to that in the original routine # denlim (now deleted). - dlimit[2] = ( + nd_plasma_electron_max_array[2] = ( 0.5e20 * p_perp**0.57 * b_plasma_toroidal_on_axis**0.31 @@ -3150,19 +3150,21 @@ def calculate_density_limit( if denom <= 0.0: if i_density_limit == 4: logger.error( - f"qcyl < 4/3; dlimit(4) set to zero; model 5 will be enforced instead. {denom=} {qcyl=}" + f"qcyl < 4/3; nd_plasma_electron_max_array(4) set to zero; model 5 will be enforced instead. {denom=} {qcyl=}" ) i_density_limit = 5 - dlimit[3] = 0.0 + nd_plasma_electron_max_array[3] = 0.0 else: - dlimit[3] = (1.0e20 * np.sqrt(p_hcd_injected_total_mw / denom)) / prn1 + nd_plasma_electron_max_array[3] = ( + 1.0e20 * np.sqrt(p_hcd_injected_total_mw / denom) + ) / prn1 # JET simplified density limit model # This applies to the density at the plasma edge, so must be scaled # to give the density limit applying to the average plasma density. - dlimit[4] = ( + nd_plasma_electron_max_array[4] = ( 0.237e20 * b_plasma_toroidal_on_axis * np.sqrt(p_plasma_separatrix_mw) @@ -3172,13 +3174,17 @@ def calculate_density_limit( # Hugill-Murakami M.q limit # qcyl=qstar here, which is okay according to the literature - dlimit[5] = 3.0e20 * b_plasma_toroidal_on_axis / (rmajor * qcyl) + nd_plasma_electron_max_array[5] = ( + 3.0e20 * b_plasma_toroidal_on_axis / (rmajor * qcyl) + ) # Greenwald limit - dlimit[6] = 1.0e14 * plasma_current / (np.pi * rminor * rminor) + nd_plasma_electron_max_array[6] = ( + 1.0e14 * plasma_current / (np.pi * rminor * rminor) + ) - dlimit[7] = ( + nd_plasma_electron_max_array[7] = ( 1.0e20 * 0.506 * (p_hcd_injected_total_mw**0.396 * (plasma_current / 1.0e6) ** 0.265) @@ -3187,7 +3193,9 @@ def calculate_density_limit( # Enforce the chosen density limit - return dlimit, dlimit[i_density_limit - 1] + return nd_plasma_electron_max_array, nd_plasma_electron_max_array[ + i_density_limit - 1 + ] @staticmethod def plasma_composition() -> None: @@ -4680,7 +4688,8 @@ def outplas(self): self.outfile, "Line-averaged electron density / Greenwald density", "(dnla_gw)", - physics_variables.nd_plasma_electron_line / physics_variables.dlimit[6], + physics_variables.nd_plasma_electron_line + / physics_variables.nd_plasma_electron_max_array[6], "OP ", ) @@ -4897,21 +4906,21 @@ def outplas(self): # must be assigned to their exisiting values# fgwped_out = ( physics_variables.nd_plasma_pedestal_electron - / physics_variables.dlimit[6] + / physics_variables.nd_plasma_electron_max_array[6] ) fgwsep_out = ( physics_variables.nd_plasma_separatrix_electron - / physics_variables.dlimit[6] + / physics_variables.nd_plasma_electron_max_array[6] ) if physics_variables.f_nd_plasma_pedestal_greenwald >= 0e0: physics_variables.f_nd_plasma_pedestal_greenwald = ( physics_variables.nd_plasma_pedestal_electron - / physics_variables.dlimit[6] + / physics_variables.nd_plasma_electron_max_array[6] ) if physics_variables.f_nd_plasma_separatrix_greenwald >= 0e0: physics_variables.f_nd_plasma_separatrix_greenwald = ( physics_variables.nd_plasma_separatrix_electron - / physics_variables.dlimit[6] + / physics_variables.nd_plasma_electron_max_array[6] ) po.ovarre( @@ -5005,57 +5014,57 @@ def outplas(self): po.ovarre( self.outfile, "Old ASDEX model", - "(dlimit(1))", - physics_variables.dlimit[0], + "(nd_plasma_electron_max_array(1))", + physics_variables.nd_plasma_electron_max_array[0], "OP ", ) po.ovarre( self.outfile, "Borrass ITER model I", - "(dlimit(2))", - physics_variables.dlimit[1], + "(nd_plasma_electron_max_array(2))", + physics_variables.nd_plasma_electron_max_array[1], "OP ", ) po.ovarre( self.outfile, "Borrass ITER model II", - "(dlimit(3))", - physics_variables.dlimit[2], + "(nd_plasma_electron_max_array(3))", + physics_variables.nd_plasma_electron_max_array[2], "OP ", ) po.ovarre( self.outfile, "JET edge radiation model", - "(dlimit(4))", - physics_variables.dlimit[3], + "(nd_plasma_electron_max_array(4))", + physics_variables.nd_plasma_electron_max_array[3], "OP ", ) po.ovarre( self.outfile, "JET simplified model", - "(dlimit(5))", - physics_variables.dlimit[4], + "(nd_plasma_electron_max_array(5))", + physics_variables.nd_plasma_electron_max_array[4], "OP ", ) po.ovarre( self.outfile, "Hugill-Murakami Mq model", - "(dlimit(6))", - physics_variables.dlimit[5], + "(nd_plasma_electron_max_array(6))", + physics_variables.nd_plasma_electron_max_array[5], "OP ", ) po.ovarre( self.outfile, "Greenwald model", - "(dlimit(7))", - physics_variables.dlimit[6], + "(nd_plasma_electron_max_array(7))", + physics_variables.nd_plasma_electron_max_array[6], "OP ", ) po.ovarre( self.outfile, "ASDEX New", - "(dlimit(8))", - physics_variables.dlimit[7], + "(nd_plasma_electron_max_array(8))", + physics_variables.nd_plasma_electron_max_array[7], "OP ", ) po.ovarre( diff --git a/process/stellarator.py b/process/stellarator.py index 16132394e4..8e7860bc9d 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -3661,7 +3661,7 @@ def stdlim(self, b_plasma_toroidal_on_axis, powht, rmajor, rminor): powht : input real : Absorbed heating power (MW) rmajor : input real : Plasma major radius (m) rminor : input real : Plasma minor radius (m) - dlimit : output real : Maximum volume-averaged plasma density (/m3) + nd_plasma_electron_max_array : output real : Maximum volume-averaged plasma density (/m3) This routine calculates the density limit for a stellarator. S.Sudo, Y.Takeiri, H.Zushi et al., Scalings of Energy Confinement and Density Limit in Stellarator/Heliotron Devices, Nuclear Fusion @@ -3686,7 +3686,7 @@ def stdlim(self, b_plasma_toroidal_on_axis, powht, rmajor, rminor): # Scale the result so that it applies to the volume-averaged # electron density - dlimit = ( + nd_plasma_electron_max_array = ( dnlamx * physics_variables.nd_plasma_electrons_vol_avg / physics_variables.nd_plasma_electron_line @@ -3694,9 +3694,9 @@ def stdlim(self, b_plasma_toroidal_on_axis, powht, rmajor, rminor): # Set the required value for icc=5 - physics_variables.dnelimt = dlimit + physics_variables.dnelimt = nd_plasma_electron_max_array - return dlimit + return nd_plasma_electron_max_array def stcoil_output( self, diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index ee6b2f9b2b..d66e4d17e8 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -2477,7 +2477,7 @@ def test_calculate_density_limit(calculatedensitylimitparam, physics): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - dlimit, dnelimt = physics.calculate_density_limit( + nd_plasma_electron_max_array, dnelimt = physics.calculate_density_limit( i_density_limit=calculatedensitylimitparam.i_density_limit, b_plasma_toroidal_on_axis=calculatedensitylimitparam.b_plasma_toroidal_on_axis, p_plasma_separatrix_mw=calculatedensitylimitparam.p_plasma_separatrix_mw, @@ -2494,7 +2494,9 @@ def test_calculate_density_limit(calculatedensitylimitparam, physics): assert dnelimt == pytest.approx(calculatedensitylimitparam.expected_dnelimt) - assert dlimit == pytest.approx(calculatedensitylimitparam.expected_dlimit) + assert nd_plasma_electron_max_array == pytest.approx( + calculatedensitylimitparam.expected_dlimit + ) class ConfinementTimeParam(NamedTuple): diff --git a/tests/unit/test_stellarator.py b/tests/unit/test_stellarator.py index 4043c2da12..42c1897bfe 100644 --- a/tests/unit/test_stellarator.py +++ b/tests/unit/test_stellarator.py @@ -2692,7 +2692,7 @@ def test_stdlim(stdlimparam, monkeypatch, stellarator): monkeypatch.setattr(physics_variables, "dnelimt", stdlimparam.dnelimt) - dlimit = stellarator.stdlim( + nd_plasma_electron_max_array = stellarator.stdlim( b_plasma_toroidal_on_axis=stdlimparam.b_plasma_toroidal_on_axis, powht=stdlimparam.powht, rmajor=stdlimparam.rmajor, @@ -2701,7 +2701,7 @@ def test_stdlim(stdlimparam, monkeypatch, stellarator): assert physics_variables.dnelimt == pytest.approx(stdlimparam.expected_dnelimt) - assert dlimit == pytest.approx(stdlimparam.expected_dlimit) + assert nd_plasma_electron_max_array == pytest.approx(stdlimparam.expected_dlimit) class StdlimEcrhParam(NamedTuple): From 92d4f7d52d87a47db61d5b73a80adaf888cf1e13 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 17:01:26 +0100 Subject: [PATCH 27/30] =?UTF-8?q?=F0=9F=94=84=20Rename=20`dnelimt`=20to=20?= =?UTF-8?q?`nd=5Fplasma=5Felectrons=5Fmax`=20across=20multiple=20files=20f?= =?UTF-8?q?or=20clarity=20and=20consistency=20in=20plasma=20density=20limi?= =?UTF-8?q?t=20calculations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/csv_output_large_tokamak_MFILE.DAT | 4 +-- examples/data/large_tokamak_1_MFILE.DAT | 4 +-- examples/data/large_tokamak_2_MFILE.DAT | 4 +-- examples/data/large_tokamak_3_MFILE.DAT | 4 +-- examples/data/large_tokamak_4_MFILE.DAT | 4 +-- examples/data/large_tokamak_nof_2_MFILE.DAT | 2 +- examples/data/large_tokamak_nof_MFILE.DAT | 4 +-- process/constraints.py | 12 +++---- process/data_structure/physics_variables.py | 8 ++--- process/io/plot_proc.py | 2 +- process/physics.py | 12 +++---- process/stellarator.py | 19 ++++++---- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/test_physics.py | 36 ++++++++++--------- tests/unit/test_stellarator.py | 16 ++++++--- 15 files changed, 74 insertions(+), 59 deletions(-) diff --git a/examples/data/csv_output_large_tokamak_MFILE.DAT b/examples/data/csv_output_large_tokamak_MFILE.DAT index c05d16abd1..88f3853e18 100644 --- a/examples/data/csv_output_large_tokamak_MFILE.DAT +++ b/examples/data/csv_output_large_tokamak_MFILE.DAT @@ -375,8 +375,8 @@ Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.6709E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8502E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP - Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4748E+19 OP - Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4748E+19 OP + Density_limit_from_scaling_(/m3)________________________________________ (nd_plasma_electron_maxma_electron_max)_____________________ 7.4748E+19 OP + Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*nd_plasma_electron_maxma_electron_max)___________ 7.4748E+19 OP Helium_ion_density_(thermalised_ions_only)_/_electron_density___________ (f_nd_alpha_electron)______________________ 8.2363E-02 ITV H__concentration________________________________________________________ (f_nd_impurity_electrons(01))____________________ 8.0759E-01 OP He_concentration________________________________________________________ (f_nd_impurity_electrons(02))____________________ 8.2363E-02 diff --git a/examples/data/large_tokamak_1_MFILE.DAT b/examples/data/large_tokamak_1_MFILE.DAT index 2efdf7c5f1..d63310ed55 100644 --- a/examples/data/large_tokamak_1_MFILE.DAT +++ b/examples/data/large_tokamak_1_MFILE.DAT @@ -376,8 +376,8 @@ Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP - Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP - Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP + Density_limit_from_scaling_(/m3)________________________________________ (nd_plasma_electron_max)_____________________ 7.4445E+19 OP + Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*nd_plasma_electron_max)___________ 7.4445E+19 OP Helium_ion_density_(thermalised_ions_only)_/_electron_density___________ (f_nd_alpha_electron)______________________ 8.3954E-02 ITV H__concentration________________________________________________________ (f_nd_impurity_electrons(01))____________________ 8.0392E-01 OP He_concentration________________________________________________________ (f_nd_impurity_electrons(02))____________________ 8.3954E-02 diff --git a/examples/data/large_tokamak_2_MFILE.DAT b/examples/data/large_tokamak_2_MFILE.DAT index 3618baa185..775c47aa6f 100644 --- a/examples/data/large_tokamak_2_MFILE.DAT +++ b/examples/data/large_tokamak_2_MFILE.DAT @@ -376,8 +376,8 @@ Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP - Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP - Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP + Density_limit_from_scaling_(/m3)________________________________________ (nd_plasma_electron_maxma_electron_max)_____________________ 7.4445E+19 OP + Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*nd_plasma_electron_maxma_electron_max)___________ 7.4445E+19 OP Helium_ion_density_(thermalised_ions_only)_/_electron_density___________ (f_nd_alpha_electron)______________________ 8.3954E-02 ITV H__concentration________________________________________________________ (f_nd_impurity_electrons(01))____________________ 8.0392E-01 OP He_concentration________________________________________________________ (f_nd_impurity_electrons(02))____________________ 8.3954E-02 diff --git a/examples/data/large_tokamak_3_MFILE.DAT b/examples/data/large_tokamak_3_MFILE.DAT index 946d276ca1..d859ed92ce 100644 --- a/examples/data/large_tokamak_3_MFILE.DAT +++ b/examples/data/large_tokamak_3_MFILE.DAT @@ -376,8 +376,8 @@ Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_protonstons)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP - Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP - Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP + Density_limit_from_scaling_(/m3)________________________________________ (nd_plasma_electron_maxma_electron_max)_____________________ 7.4445E+19 OP + Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*nd_plasma_electron_maxma_electron_max)___________ 7.4445E+19 OP Helium_ion_density_(thermalised_ions_only)_/_electron_density___________ (f_nd_alpha_electron)______________________ 8.3954E-02 ITV H__concentration________________________________________________________ (f_nd_impurity_electrons(01))____________________ 8.0392E-01 OP He_concentration________________________________________________________ (f_nd_impurity_electrons(02))____________________ 8.3954E-02 diff --git a/examples/data/large_tokamak_4_MFILE.DAT b/examples/data/large_tokamak_4_MFILE.DAT index 3e172276fb..45ae23dac8 100644 --- a/examples/data/large_tokamak_4_MFILE.DAT +++ b/examples/data/large_tokamak_4_MFILE.DAT @@ -376,8 +376,8 @@ Helium_ion_density_(thermalised_ions_only)_(/m3)________________________ (nd_plasma_alphas_vol_avg_alphas_vol_avg)_______________________ 6.7723E+18 OP Proton_density_(/m3)____________________________________________________ (nd_plasma_protons_vol_avg)______________________ 1.8963E+16 OP Hot_beam_density_(/m3)__________________________________________________ (nd_beam_ions)______________________ 0.0000E+00 OP - Density_limit_from_scaling_(/m3)________________________________________ (dnelimt)_____________________ 7.4445E+19 OP - Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*dnelimt)___________ 7.4445E+19 OP + Density_limit_from_scaling_(/m3)________________________________________ (nd_plasma_electron_maxma_electron_max)_____________________ 7.4445E+19 OP + Density_limit_(enforced)_(/m3)__________________________________________ (boundu(9)*nd_plasma_electron_maxma_electron_max)___________ 7.4445E+19 OP Helium_ion_density_(thermalised_ions_only)_/_electron_density___________ (f_nd_alpha_electron)______________________ 8.3954E-02 ITV H__concentration________________________________________________________ (f_nd_impurity_electrons(01))____________________ 8.0392E-01 OP He_concentration________________________________________________________ (f_nd_impurity_electrons(02))____________________ 8.3954E-02 diff --git a/examples/data/large_tokamak_nof_2_MFILE.DAT b/examples/data/large_tokamak_nof_2_MFILE.DAT index 29f6fa469c..47eac702e1 100644 --- a/examples/data/large_tokamak_nof_2_MFILE.DAT +++ b/examples/data/large_tokamak_nof_2_MFILE.DAT @@ -283,7 +283,7 @@ Hugill-Murakami_Mq_model_________________________________________________ (nd_plasma_electron_max_array(6))____________________ 4.83130102547807273e+19 OP Greenwald_model__________________________________________________________ (nd_plasma_electron_max_array(7))____________________ 7.20274886424344904e+19 OP ASDEX_New________________________________________________________________ (nd_plasma_electron_max_array(8))____________________ 8.37005006999513989e+20 OP - Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.20274886424344904e+19 OP + Density_limit_from_scaling_(/m3)_________________________________________ (nd_plasma_electron_max)______________________ 7.20274886424344904e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 3-Helium_fuel_fraction___________________________________________________ (f_plasma_fuel_helium3)____________________ 0.00000000000000000e+00 diff --git a/examples/data/large_tokamak_nof_MFILE.DAT b/examples/data/large_tokamak_nof_MFILE.DAT index 33c0e0efbd..01f26fab5d 100644 --- a/examples/data/large_tokamak_nof_MFILE.DAT +++ b/examples/data/large_tokamak_nof_MFILE.DAT @@ -355,8 +355,8 @@ Hugill-Murakami_Mq_model_________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(6))____________________ 5.26219719824596337e+19 OP Greenwald_model__________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(7))____________________ 7.84515075612383478e+19 OP ASDEX_New________________________________________________________________ (nd_plasma_electron_max_arraysma_electron_max_array(8))____________________ 1.03091554466307611e+21 OP - Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.84515075612383478e+19 OP - Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*dnelimt)____________ 7.84515075612383478e+19 OP + Density_limit_from_scaling_(/m3)_________________________________________ (nd_plasma_electron_maxma_electron_max)______________________ 7.84515075612383478e+19 OP + Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*nd_plasma_electron_maxma_electron_max)____________ 7.84515075612383478e+19 OP Deuterium_fuel_fraction__________________________________________________ (f_plasma_fuel_deuterium)__________________ 5.00000000000000000e-01 Tritium_fuel_fraction____________________________________________________ (f_plasma_fuel_tritium)____________________ 5.00000000000000000e-01 3-Helium_fuel_fraction___________________________________________________ (f_plasma_fuel_helium3)____________________ 0.00000000000000000e+00 diff --git a/process/constraints.py b/process/constraints.py index ea870b37b0..ec58009caa 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -357,7 +357,7 @@ def constraint_equation_5(): fdene: f-value for density limit nd_plasma_electrons_vol_avg: electron density (/m3) - dnelimt: density limit (/m3) + nd_plasma_electrons_max: density limit (/m3) nd_plasma_electron_line: line averaged electron density (m-3) i_density_limit: @@ -373,23 +373,23 @@ def constraint_equation_5(): if data_structure.physics_variables.i_density_limit == 7: return ConstraintResult( data_structure.physics_variables.nd_plasma_electron_line - / data_structure.physics_variables.dnelimt + / data_structure.physics_variables.nd_plasma_electrons_max - 1.0 * data_structure.constraint_variables.fdene, data_structure.constraint_variables.fdene - * data_structure.physics_variables.dnelimt, + * data_structure.physics_variables.nd_plasma_electrons_max, data_structure.constraint_variables.fdene - * data_structure.physics_variables.dnelimt + * data_structure.physics_variables.nd_plasma_electrons_max - data_structure.physics_variables.nd_plasma_electron_line, ) cc = ( data_structure.physics_variables.nd_plasma_electrons_vol_avg - / data_structure.physics_variables.dnelimt + / data_structure.physics_variables.nd_plasma_electrons_max - 1.0 * data_structure.constraint_variables.fdene ) return ConstraintResult( cc, - data_structure.physics_variables.dnelimt * (1.0 - cc), + data_structure.physics_variables.nd_plasma_electrons_max * (1.0 - cc), data_structure.physics_variables.nd_plasma_electrons_vol_avg * cc, ) diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index 2a401d81c7..c33ae2016f 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -382,8 +382,8 @@ """Stambaugh-like coefficient for beta scaling""" -dnelimt: float = None -"""density limit (/m3)""" +nd_plasma_electrons_max: float = None +"""Plasma electron max density limit (/m3)""" nd_plasma_ions_total_vol_avg: float = None @@ -1417,7 +1417,7 @@ def init_physics_variables(): global beta_norm_max_original_scaling global beta_norm_max_tholerus global beta_norm_max_stambaugh - global dnelimt + global nd_plasma_electrons_max global nd_plasma_ions_total_vol_avg global nd_plasma_electron_line global nd_plasma_protons_vol_avg @@ -1670,7 +1670,7 @@ def init_physics_variables(): beta_norm_max_original_scaling = 0.0 beta_norm_max_tholerus = 0.0 beta_norm_max_stambaugh = 0.0 - dnelimt = 0.0 + nd_plasma_electrons_max = 0.0 nd_plasma_ions_total_vol_avg = 0.0 nd_plasma_electron_line = 0.0 nd_plasma_protons_vol_avg = 0.0 diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index f36aea42cc..eee1761b56 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -3118,7 +3118,7 @@ def plot_main_plasma_information( # Add density limit information textstr_density_limit = ( f"$\\mathbf{{Density \\ limit:}}$\n\n" - f"$n_{{\\text{{e,limit}}}}: {mfile_data.data['dnelimt'].get_scan(scan):.3e} \\ m^{{-3}}$\n" + f"$n_{{\\text{{e,limit}}}}: {mfile_data.data['nd_plasma_electrons_max'].get_scan(scan):.3e} \\ m^{{-3}}$\n" ) axis.text( diff --git a/process/physics.py b/process/physics.py index 20fa583c22..736ae760e0 100644 --- a/process/physics.py +++ b/process/physics.py @@ -2460,7 +2460,7 @@ def physics(self): # Density limit ( physics_variables.nd_plasma_electron_max_array, - physics_variables.dnelimt, + physics_variables.nd_plasma_electrons_max, ) = self.calculate_density_limit( physics_variables.b_plasma_toroidal_on_axis, physics_variables.i_density_limit, @@ -3075,7 +3075,7 @@ def calculate_density_limit( Returns: Tuple[np.ndarray, float]: A tuple containing: - nd_plasma_electron_max_array (np.ndarray): Average plasma density limit using seven different models (m^-3). - - dnelimt (float): Enforced average plasma density limit (m^-3). + - nd_plasma_electrons_max (float): Enforced average plasma density limit (m^-3). Raises: ValueError: If i_density_limit is not between 1 and 7. @@ -5070,16 +5070,16 @@ def outplas(self): po.ovarre( self.outfile, "Density limit from scaling (/m3)", - "(dnelimt)", - physics_variables.dnelimt, + "(nd_plasma_electrons_max)", + physics_variables.nd_plasma_electrons_max, "OP ", ) if (numerics.ioptimz > 0) and (numerics.active_constraints[4]): po.ovarre( self.outfile, "Density limit (enforced) (/m3)", - "(boundu(9)*dnelimt)", - numerics.boundu[8] * physics_variables.dnelimt, + "(boundu(9)*nd_plasma_electrons_max)", + numerics.boundu[8] * physics_variables.nd_plasma_electrons_max, "OP ", ) diff --git a/process/stellarator.py b/process/stellarator.py index 8e7860bc9d..24c8d3595a 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -281,7 +281,7 @@ def stopt(self, output: bool): This routine reiterates some physics modules. """ - physics_variables.dnelimt = self.stdlim( + physics_variables.nd_plasma_electrons_max = self.stdlim( physics_variables.b_plasma_toroidal_on_axis, physics_variables.p_plasma_loss_mw, physics_variables.rmajor, @@ -3694,7 +3694,7 @@ def stdlim(self, b_plasma_toroidal_on_axis, powht, rmajor, rminor): # Set the required value for icc=5 - physics_variables.dnelimt = nd_plasma_electron_max_array + physics_variables.nd_plasma_electrons_max = nd_plasma_electron_max_array return nd_plasma_electron_max_array @@ -4723,7 +4723,7 @@ def stphys(self, output): nu_star_T, nu_star_He, physics_variables.nd_plasma_electron_line, - physics_variables.dnelimt, + physics_variables.nd_plasma_electrons_max, ) def stphys_output( @@ -4747,7 +4747,7 @@ def stphys_output( nu_star_T, nu_star_He, nd_plasma_electron_line, - dnelimt, + nd_plasma_electrons_max, ): po.oheadr(self.outfile, "Stellarator Specific Physics:") @@ -4857,12 +4857,17 @@ def stphys_output( "(nd_plasma_electron_line)", nd_plasma_electron_line, ) - po.ovarre(self.outfile, "Sudo density limit (/m3)", "(dnelimt)", dnelimt) + po.ovarre( + self.outfile, + "Sudo density limit (/m3)", + "(nd_plasma_electrons_max)", + nd_plasma_electrons_max, + ) po.ovarre( self.outfile, "Ratio density to sudo limit (1)", - "(nd_plasma_electron_line/dnelimt)", - nd_plasma_electron_line / dnelimt, + "(nd_plasma_electron_line/nd_plasma_electrons_max)", + nd_plasma_electron_line / nd_plasma_electrons_max, ) def calc_neoclassics(self): diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index afcdc453e7..c0204e9de5 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -237,7 +237,7 @@ triang = 0.5 icc = 5 * DESCRIPTION: Density Upper Limit * JUSTIFICATION: Used to enforce Greenwald limit -* VARIABLES: dnelimt & nd_plasma_electron_line calculated in-situ +* VARIABLES: nd_plasma_electrons_max & nd_plasma_electron_line calculated in-situ i_density_limit = 7 * DESCRIPTION: Switch for Density Limit to Enforce (icc=5) (7: Greenwald Limit) diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index d66e4d17e8..42dcefb43c 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -2477,22 +2477,26 @@ def test_calculate_density_limit(calculatedensitylimitparam, physics): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - nd_plasma_electron_max_array, dnelimt = physics.calculate_density_limit( - i_density_limit=calculatedensitylimitparam.i_density_limit, - b_plasma_toroidal_on_axis=calculatedensitylimitparam.b_plasma_toroidal_on_axis, - p_plasma_separatrix_mw=calculatedensitylimitparam.p_plasma_separatrix_mw, - p_hcd_injected_total_mw=calculatedensitylimitparam.p_hcd_injected_total_mw, - plasma_current=calculatedensitylimitparam.plasma_current, - prn1=calculatedensitylimitparam.prn1, - q95=calculatedensitylimitparam.q95, - qcyl=calculatedensitylimitparam.qcyl, - rmajor=calculatedensitylimitparam.rmajor, - rminor=calculatedensitylimitparam.rminor, - a_plasma_surface=calculatedensitylimitparam.a_plasma_surface, - zeff=calculatedensitylimitparam.zeff, - ) - - assert dnelimt == pytest.approx(calculatedensitylimitparam.expected_dnelimt) + nd_plasma_electron_max_array, nd_plasma_electrons_max = ( + physics.calculate_density_limit( + i_density_limit=calculatedensitylimitparam.i_density_limit, + b_plasma_toroidal_on_axis=calculatedensitylimitparam.b_plasma_toroidal_on_axis, + p_plasma_separatrix_mw=calculatedensitylimitparam.p_plasma_separatrix_mw, + p_hcd_injected_total_mw=calculatedensitylimitparam.p_hcd_injected_total_mw, + plasma_current=calculatedensitylimitparam.plasma_current, + prn1=calculatedensitylimitparam.prn1, + q95=calculatedensitylimitparam.q95, + qcyl=calculatedensitylimitparam.qcyl, + rmajor=calculatedensitylimitparam.rmajor, + rminor=calculatedensitylimitparam.rminor, + a_plasma_surface=calculatedensitylimitparam.a_plasma_surface, + zeff=calculatedensitylimitparam.zeff, + ) + ) + + assert nd_plasma_electrons_max == pytest.approx( + calculatedensitylimitparam.expected_dnelimt + ) assert nd_plasma_electron_max_array == pytest.approx( calculatedensitylimitparam.expected_dlimit diff --git a/tests/unit/test_stellarator.py b/tests/unit/test_stellarator.py index 42c1897bfe..85c8bbab95 100644 --- a/tests/unit/test_stellarator.py +++ b/tests/unit/test_stellarator.py @@ -2623,7 +2623,7 @@ class StdlimParam(NamedTuple): nd_plasma_electron_line: Any = None - dnelimt: Any = None + nd_plasma_electrons_max: Any = None b_plasma_toroidal_on_axis: Any = None @@ -2644,7 +2644,7 @@ class StdlimParam(NamedTuple): StdlimParam( nd_plasma_electrons_vol_avg=2.0914e20, nd_plasma_electron_line=2.357822619799476e20, - dnelimt=0, + nd_plasma_electrons_max=0, b_plasma_toroidal_on_axis=5.5, powht=432.20449197454559, rmajor=22, @@ -2655,7 +2655,7 @@ class StdlimParam(NamedTuple): StdlimParam( nd_plasma_electrons_vol_avg=2.0914e20, nd_plasma_electron_line=2.357822619799476e20, - dnelimt=1.2918765671497731e20, + nd_plasma_electrons_max=1.2918765671497731e20, b_plasma_toroidal_on_axis=5.5, powht=431.98698920075435, rmajor=22, @@ -2690,7 +2690,11 @@ def test_stdlim(stdlimparam, monkeypatch, stellarator): stdlimparam.nd_plasma_electron_line, ) - monkeypatch.setattr(physics_variables, "dnelimt", stdlimparam.dnelimt) + monkeypatch.setattr( + physics_variables, + "nd_plasma_electrons_max", + stdlimparam.nd_plasma_electrons_max, + ) nd_plasma_electron_max_array = stellarator.stdlim( b_plasma_toroidal_on_axis=stdlimparam.b_plasma_toroidal_on_axis, @@ -2699,7 +2703,9 @@ def test_stdlim(stdlimparam, monkeypatch, stellarator): rminor=stdlimparam.rminor, ) - assert physics_variables.dnelimt == pytest.approx(stdlimparam.expected_dnelimt) + assert physics_variables.nd_plasma_electrons_max == pytest.approx( + stdlimparam.expected_dnelimt + ) assert nd_plasma_electron_max_array == pytest.approx(stdlimparam.expected_dlimit) From ae2aff9a7b789cc7c9ad4a12db6fb8cb39e2e53b Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 17 Oct 2025 17:29:34 +0100 Subject: [PATCH 28/30] :memo: Update volume averaged thermal beta definitions for clarity and consistency in plasma beta calculations. --- .../physics-models/plasma_beta/plasma_beta.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/documentation/physics-models/plasma_beta/plasma_beta.md b/documentation/physics-models/plasma_beta/plasma_beta.md index 52c3441fed..7ae8b4ffef 100644 --- a/documentation/physics-models/plasma_beta/plasma_beta.md +++ b/documentation/physics-models/plasma_beta/plasma_beta.md @@ -106,16 +106,28 @@ $$ ### Volume averaged thermal toroidal beta +We define $B_{\text{T,on-axis}}$ as the toroidal field at the plasma major radius, $R_0$ + $$ -\overbrace{\langle \beta_t \rangle}^{\texttt{beta_toroidal_thermal_vol_avg}} = \frac{2\mu_0 \langle p_{\text{thermal}} \rangle}{\underbrace{B_{\text{T,on-axis}}^2}_{\texttt{b_plasma_toroidal_on_axis}}} +\overbrace{\langle \beta_t \rangle_{\text{V}}}^{\texttt{beta_toroidal_thermal_vol_avg}} = \frac{2\mu_0 \overbrace{\langle p_{\text{thermal}} \rangle}^{\texttt{pres_plasma_thermal_vol_avg}}}{\underbrace{B_{\text{T,on-axis}}^2}_{\texttt{b_plasma_toroidal_on_axis}}} $$ ### Volume averaged thermal poloidal beta + + +$$ +\overbrace{\langle \beta_p \rangle_{\text{V}}}^{\texttt{beta_poloidal_thermal_vol_avg}} = \frac{2\mu_0 \overbrace{\langle p_{\text{thermal}} \rangle}^{\texttt{pres_plasma_thermal_vol_avg}}}{\underbrace{\langle B_{\text{P,average}} \rangle^2}_{\texttt{b_plasma_poloidal_average}}} +$$ + +### Volume averaged thermal beta + $$ -\langle \beta_p \rangle = \frac{2\mu_0 \langle p_{\text{thermal}} \rangle}{\langle B_{\text{P,average}} \rangle^2} +\overbrace{\langle \beta \rangle_{\text{V}}}^{\texttt{beta_thermal_vol_avg}} = \frac{2\mu_0 \overbrace{\langle p_{\text{thermal}} \rangle}^{\texttt{pres_plasma_thermal_vol_avg}}}{\sqrt{\langle B_{\text{P,average}} \rangle^2+B_{\text{T,on-axis}}^2}} $$ +------------------ + ## Troyon Beta Limit The Troyon plasma beta limit is given by[^0][^1]: From 63ea1c716a05142343d97d5cf1bb5497a3aecd93 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 21 Oct 2025 10:07:40 +0100 Subject: [PATCH 29/30] update integration test data --- tests/integration/data/large_tokamak_MFILE.DAT | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/data/large_tokamak_MFILE.DAT b/tests/integration/data/large_tokamak_MFILE.DAT index 71c4d5aadd..092bb0ba4a 100644 --- a/tests/integration/data/large_tokamak_MFILE.DAT +++ b/tests/integration/data/large_tokamak_MFILE.DAT @@ -514,14 +514,14 @@ Temperature_profile_index________________________________________________ (alphat)_______________________ 1.44999999999999996e+00 Temperature_profile_index_beta___________________________________________ (tbeta)________________________ 2.00000000000000000e+00 Pressure_profile_index___________________________________________________ (alphap)_______________________ 2.45000000000000018e+00 - Old_ASDEX_model__________________________________________________________ (dlimit(1))____________________ 5.25099867300934042e+19 OP - Borrass_ITER_model_I_____________________________________________________ (dlimit(2))____________________ 1.10261258000869769e+20 OP - Borrass_ITER_model_II____________________________________________________ (dlimit(3))____________________ 4.40600572159738593e+19 OP - JET_edge_radiation_model_________________________________________________ (dlimit(4))____________________ 2.07011284460869072e+21 OP - JET_simplified_model_____________________________________________________ (dlimit(5))____________________ 4.51355754064512156e+20 OP - Hugill-Murakami_Mq_model_________________________________________________ (dlimit(6))____________________ 6.61224227410254889e+19 OP - Greenwald_model__________________________________________________________ (dlimit(7))____________________ 7.39017783374919762e+19 OP - ASDEX_New________________________________________________________________ (dlimit(8))____________________ 8.69749494782652973e+20 OP + Old_ASDEX_model__________________________________________________________ (nd_plasma_electron_max_array(1))____________________ 2.90898762676047462e+19 OP + Borrass_ITER_model_I_____________________________________________________ (nd_plasma_electron_max_array(2))____________________ 5.32771894980833526e+19 OP + Borrass_ITER_model_II____________________________________________________ (nd_plasma_electron_max_array(3))____________________ 2.01519696896069632e+19 OP + JET_edge_radiation_model_________________________________________________ (nd_plasma_electron_max_array(4))____________________ 1.71437007414591567e+21 OP + JET_simplified_model_____________________________________________________ (nd_plasma_electron_max_array(5))____________________ 2.21998796377134301e+20 OP + Hugill-Murakami_Mq_model_________________________________________________ (nd_plasma_electron_max_array(6))____________________ 4.83130102547807273e+19 OP + Greenwald_model__________________________________________________________ (nd_plasma_electron_max_array(7))____________________ 7.20274886424344904e+19 OP + ASDEX_New________________________________________________________________ (nd_plasma_electron_max_array(8))____________________ 8.37005006999513989e+20 OP Density_limit_from_scaling_(/m3)_________________________________________ (dnelimt)______________________ 7.39017783374919762e+19 OP Density_limit_(enforced)_(/m3)___________________________________________ (boundu(9)*dnelimt)____________ 7.39017783374919762e+19 OP # Plasma Reactions : # From 40ffce9c6fe25dc0179aee9ae30121e78a14d04b Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 21 Oct 2025 10:48:58 +0100 Subject: [PATCH 30/30] Update obsolete vars --- process/data_structure/physics_variables.py | 2 +- process/io/obsolete_vars.py | 6 ++++++ tests/regression/input_files/large_tokamak_eval.IN.DAT | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index c33ae2016f..ef794eada1 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -343,7 +343,7 @@ nd_plasma_electron_max_array: list[float] = None -"""Plasma electron density max limit model array (/m3)""" +"""Array of plasma electron density upper limits values (/m3)""" nd_plasma_alphas_vol_avg: float = None diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 950cb9f05c..edd9f3774b 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -457,6 +457,12 @@ "rebco_thickness": "dx_hts_tape_rebco", "tape_thickness": "dx_hts_tape_total", "tape_width": "dr_hts_tape", + "beta": "beta_total_vol_avg", + "beta_max": "beta_vol_avg_max", + "beta_min": "beta_vol_avg_min", + "f_deuterium": "f_plasma_fuel_deuterium", + "f_tritium": "f_plasma_fuel_tritium", + "f_helium3": "f_plasma_fuel_helium3", } OBS_VARS_HELP = { diff --git a/tests/regression/input_files/large_tokamak_eval.IN.DAT b/tests/regression/input_files/large_tokamak_eval.IN.DAT index fcabf41f36..6bb0064265 100644 --- a/tests/regression/input_files/large_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/large_tokamak_eval.IN.DAT @@ -280,7 +280,7 @@ alphan = 1.00 * density profile index alphat = 1.45 * temperature profile index i_alphaj = 1 * Current profile index selection (0 = user input) aspect = 3.0 * aspect ratio (`iteration variable 1`) -beta = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) +beta_total_vol_avg = 0.03230408815355488 * total plasma beta (`iteration variable 5`) (calculated if stellarator) b_plasma_toroidal_on_axis = 5.318322174644904 * toroidal field on axis (T) (`iteration variable 2`) nd_plasma_electrons_vol_avg = 7.796223900029837e+19 * electron density (/m3) (`iteration variable 6`) beta_norm_max = 3.0 * Troyon-like coefficient for beta scaling calculated