Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
31505e3
Refactor docstrings for clarity and consistency in the plasma profile…
chris-ashe May 6, 2026
c09ca04
Improve docstring formatting and clarity in plasma profile classes
chris-ashe May 6, 2026
96ec390
Lint plasma fields
chris-ashe May 6, 2026
e829c23
Lint plasma_current.py
chris-ashe May 6, 2026
f3416d3
Enhance docstring clarity and formatting in l_h_transition.py
chris-ashe May 7, 2026
60c5cf9
Enhance docstring clarity and formatting in fusion_reactions.py
chris-ashe May 7, 2026
fcad222
Enhance docstring clarity and formatting in exhaust.py
chris-ashe May 7, 2026
23ac52a
Enhance docstring clarity and formatting in density_limit.py
chris-ashe May 7, 2026
3a7c014
Implement feature X to enhance user experience and optimize performance
chris-ashe May 7, 2026
41cc919
Enhance docstring clarity and formatting in bootstrap_current.py
chris-ashe May 7, 2026
54e8c5f
Enhance docstring formatting and clarity in radiation_power.py
chris-ashe May 7, 2026
05eebf3
Enhance docstring clarity and formatting in plasma_geometry.py
chris-ashe May 7, 2026
8e32955
Enhance docstring clarity for PlasmaProfileShapeType methods
chris-ashe May 7, 2026
78dd3b3
Enhance docstring formatting for PlasmaProfile class to improve clarity
chris-ashe May 7, 2026
537c89a
Enhance docstring formatting in plasma_profiles.py for clarity
chris-ashe May 7, 2026
d9e9f3e
Enhance docstring clarity and formatting in impurity_radiation.py
chris-ashe May 7, 2026
0d54c7f
Enhance docstring clarity and formatting in current_drive.py for impr…
chris-ashe May 7, 2026
ad1792d
Refactor NeutralBeam class methods for improved readability and param…
chris-ashe May 7, 2026
ee1412d
Potential fix for pull request finding
chris-ashe May 7, 2026
b612b1f
Potential fix for pull request finding
chris-ashe May 7, 2026
3194d0a
Potential fix for pull request finding
chris-ashe May 7, 2026
a1d539f
Update process/models/physics/exhaust.py
chris-ashe May 7, 2026
1226399
Update process/models/physics/density_limit.py
chris-ashe May 7, 2026
99703e9
Update process/models/physics/bootstrap_current.py
chris-ashe May 7, 2026
342a94b
Update process/models/physics/plasma_profiles.py
chris-ashe May 7, 2026
66e20aa
Update process/models/physics/physics.py
chris-ashe May 7, 2026
c98d21a
Fix comment formatting in PlasmaBootstrapCurrent class
chris-ashe May 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
408 changes: 254 additions & 154 deletions process/models/physics/bootstrap_current.py

Large diffs are not rendered by default.

444 changes: 292 additions & 152 deletions process/models/physics/confinement_time.py

Large diffs are not rendered by default.

504 changes: 293 additions & 211 deletions process/models/physics/current_drive.py

Large diffs are not rendered by default.

80 changes: 61 additions & 19 deletions process/models/physics/density_limit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""Plasma density limit models and calculations.

This module provides various electron density limit models used in plasma
physics calculations, including ASDEX, Borrass, JET, Hugill Murakami, and
Greenwald limits.
"""

import logging
from enum import IntEnum
from types import DynamicClassAttribute
Expand Down Expand Up @@ -28,14 +35,29 @@ class DensityLimitModel(IntEnum):
GREENWALD = (7, "Greenwald limit")
ASDEX_NEW = (8, "ASDEX New limit")

def __new__(cls, value, full_name):
def __new__(cls, value: int, full_name: str):
"""Create a new DensityLimitModel instance.

Parameters
----------
value : int
The integer value for the enum member.
full_name : str
The full descriptive name of the density limit model.

Returns
-------
obj
A new instance of DensityLimitModel.
"""
obj = int.__new__(cls, value)
obj._value_ = value
obj._full_name_ = full_name
return obj

@DynamicClassAttribute
def full_name(self):
"""Return the full name of the density limit model."""
return self._full_name_


Expand All @@ -47,6 +69,13 @@ def __init__(self):
self.mfile = constants.MFILE

def run(self):
"""Calculate plasma density limits and update physics variables.

Raises
------
ProcessValueError
If i_density_limit has an illegal value.
"""
physics_variables.nd_plasma_electron_max_array, _ = self.calculate_density_limit(
b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
i_density_limit=physics_variables.i_density_limit,
Expand Down Expand Up @@ -74,7 +103,8 @@ def run(self):
i_density_limit=physics_variables.i_density_limit,
) from None

def get_density_limit_value(self, model: DensityLimitModel) -> float:
@staticmethod
def get_density_limit_value(model: DensityLimitModel) -> float:
"""
Get the density limit value (n_e_max) for the specified model.

Expand Down Expand Up @@ -145,7 +175,8 @@ def calculate_asdex_density_limit(

References
----------
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study',
AEA FUS 172, 1992
"""
return (
1.54e20
Expand Down Expand Up @@ -185,7 +216,8 @@ def calculate_borrass_iter_i_density_limit(

References
----------
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study',
AEA FUS 172, 1992
"""
return (
1.8e20
Expand Down Expand Up @@ -225,7 +257,8 @@ def calculate_borrass_iter_ii_density_limit(

References
----------
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study',
AEA FUS 172, 1992
"""
return (
0.5e20
Expand Down Expand Up @@ -259,7 +292,8 @@ def calculate_jet_edge_radiation_density_limit(

References
----------
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study',
AEA FUS 172, 1992
"""
denom = (zeff - 1.0) * (1.0 - 4.0 / (3.0 * qcyl))
if denom <= 0.0:
Expand Down Expand Up @@ -294,7 +328,8 @@ def calculate_jet_simple_density_limit(

References
----------
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study', AEA FUS 172, 1992
T.C.Hender et.al., 'Physics Assesment of the European Reactor Study',
AEA FUS 172, 1992
"""
return (
0.237e20
Expand Down Expand Up @@ -388,15 +423,17 @@ def calculate_asdex_new_density_limit(

Notes
-----
This limit is for the separatrix density so we scale by `prn1` to get it as a volume average.
This limit is for the separatrix density so we scale by `prn1` to get it as a
volume average.

References
----------
J. W. Berkery et al., "Density limits as disruption forecasters for spherical tokamaks,"
Plasma Physics and Controlled Fusion, vol. 65, no. 9, pp. 095003-095003, Jul. 2023,
doi: https://doi.org/10.1088/1361-6587/ace476.
J. W. Berkery et al., "Density limits as disruption forecasters for spherical
tokamaks," Plasma Physics and Controlled Fusion, vol. 65, no. 9,
pp. 095003-095003, Jul. 2023, doi: https://doi.org/10.1088/1361-6587/ace476.

M. Bernert et al., "The H-mode density limit in the full tungsten ASDEX Upgrade tokamak," vol. 57, no. 1, pp. 014038-014038, Nov. 2014,
M. Bernert et al., "The H-mode density limit in the full tungsten ASDEX
Upgrade tokamak," vol. 57, no. 1, pp. 014038-014038, Nov. 2014,
doi: https://doi.org/10.1088/0741-3335/57/1/014038.
"""
return (
Expand Down Expand Up @@ -455,27 +492,31 @@ def calculate_density_limit(
-------
tuple[np.ndarray, float]
A tuple containing:
- nd_plasma_electron_max_array : Average plasma density limit using eight different models (m⁻³).
- nd_plasma_electron_max_array : Average plasma density limit using eight
different models (m⁻³).
- nd_plasma_electrons_max : Enforced average plasma density limit (m⁻³).

Raises
------
ValueError
ProcessValueError
If i_density_limit is not between 1 and 7.

Notes
-----
This routine calculates several different formulae for the density limit and enforces the one chosen by the user.
For i_density_limit = 1-5, 8, we scale the separatrix density limit output by the ratio of the separatrix to volume averaged density.
This routine calculates several different formulae for the density limit and
enforces the one chosen by the user. For i_density_limit = 1-5, 8, we scale the
separatrix density limit output by the ratio of the separatrix to volume
averaged density.

References
----------
AEA FUS 172: Physics Assessment for the European Reactor Study

N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989'

M. Bernert et al., "The H-mode density limit in the full tungsten ASDEX Upgrade tokamak,"
vol. 57, no. 1, pp. 014038-014038, Nov. 2014, doi: https://doi.org/10.1088/0741-3335/57/1/014038.
M. Bernert et al., "The H-mode density limit in the full tungsten ASDEX Upgrade
tokamak," vol. 57, no. 1, pp. 014038-014038, Nov. 2014,
doi: https://doi.org/10.1088/0741-3335/57/1/014038.
"""
if i_density_limit < 1 or i_density_limit > 7:
raise ProcessValueError(
Expand Down Expand Up @@ -590,7 +631,8 @@ def output_density_limit_information(self):
)
po.ocmmnt(
self.outfile,
f"Density limit model selected: {DensityLimitModel(physics_variables.i_density_limit).full_name} ",
"Density limit model selected: "
f"{DensityLimitModel(physics_variables.i_density_limit).full_name}",
)
po.ovarre(
self.outfile,
Expand Down
23 changes: 15 additions & 8 deletions process/models/physics/exhaust.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module for plasma exhaust calculations and analysis."""

import logging

from process.core import constants
Expand Down Expand Up @@ -30,7 +32,8 @@ def output(self):

if physics_variables.p_plasma_separatrix_mw <= 0.001e0:
logger.error(
"Possible problem with high radiation power, forcing p_plasma_separatrix_mw to odd values. "
"Possible problem with high radiation power, forcing "
"p_plasma_separatrix_mw to odd values. "
f"{physics_variables.p_plasma_separatrix_mw=}"
)
po.oblnkl(self.outfile)
Expand All @@ -48,14 +51,16 @@ def output(self):
# Double null divertor configuration
po.ovarre(
self.outfile,
"Plasma separatrix power over major radius (Pₛₑₚ / R₀) (MW/m) (On peak divertor)",
"Plasma separatrix power over major radius (Pₛₑₚ / R₀) (MW/m) "
"(On peak divertor)",
"(p_plasma_separatrix_rmajor_mw)",
physics_variables.p_plasma_separatrix_rmajor_mw,
"OP ",
)
po.ovarre(
self.outfile,
"EU-DEMO divertor protection re-attachment metric (PₛₑₚBₜ / q₉₅AR₀) (MWT/m) (On peak divertor)",
"EU-DEMO divertor protection re-attachment metric (PₛₑₚBₜ / q₉₅AR₀) "
"(MWT/m) (On peak divertor)",
"(p_div_bt_q_aspect_rmajor_mw)",
physics_variables.p_div_bt_q_aspect_rmajor_mw,
"OP ",
Expand All @@ -71,7 +76,8 @@ def output(self):
)
po.ovarre(
self.outfile,
"EU-DEMO divertor protection re-attachment metric (PₛₑₚBₜ / q₉₅AR₀) (MWT/m)",
"EU-DEMO divertor protection re-attachment metric (PₛₑₚBₜ / q₉₅AR₀) "
"(MWT/m)",
"(p_div_bt_q_aspect_rmajor_mw)",
physics_variables.p_div_bt_q_aspect_rmajor_mw,
"OP ",
Expand Down Expand Up @@ -148,7 +154,8 @@ def calculate_eu_demo_re_attachment_metric(
aspect: float,
rmajor: float,
) -> float:
"""Calculate the EU DEMO divertor protection re-attachment metric for plasma exhaust.
"""Calculate the EU DEMO divertor protection re-attachment metric for plasma
exhaust.

Parameters
----------
Expand All @@ -171,9 +178,9 @@ def calculate_eu_demo_re_attachment_metric(
References
----------
- M. Siccinio, G. Federici, R. Kembleton, H. Lux, F. Maviglia, and J. Morris,
"Figure of merit for divertor protection in the preliminary design of the EU-DEMO reactor,"
Nuclear Fusion, vol. 59, no. 10, pp. 106026-106026, Jul. 2019,
doi: https://doi.org/10.1088/1741-4326/ab3153.
"Figure of merit for divertor protection in the preliminary design of the
EU-DEMO reactor," Nuclear Fusion, vol. 59, no. 10, pp. 106026-106026,
Jul. 2019, doi: https://doi.org/10.1088/1741-4326/ab3153.

- H. Zohm et al.,
"A stepladder approach to a tokamak fusion power plant,"
Expand Down
Loading
Loading