From aa125378a1baa2aca4b16a48aff07b30b209f177 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:17:06 +0100 Subject: [PATCH 01/10] Refactor __init__ method docstring to use NumPy style for parameters Co-authored-by: Copilot --- process/core/io/in_dat/base.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py index bf43a27fc..f63095034 100644 --- a/process/core/io/in_dat/base.py +++ b/process/core/io/in_dat/base.py @@ -1708,14 +1708,16 @@ class StructuredInputData: self.data["parameters"]["physics_variables"]["i_plasma_geometry"]["value"] = 0 """ - def __init__(self, filename="IN.DAT"): + def __init__(self, filename: str = "IN.DAT"): """Use InDat to create the data dict. Use InDat to read in an input file and store the data, then construct a structured input data dict from it. - :param filename: input data filename, defaults to "IN.DAT" - :type filename: str, optional + Parameters + ---------- + filename : + Input data filename, defaults to "IN.DAT" """ self.data = {} # Structured input data dict From b82044f73d09b9138adfb4e234f2d76087220a98 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:17:51 +0100 Subject: [PATCH 02/10] Refactor __init__ method docstring to use NumPy style for parameters Co-authored-by: Copilot --- process/core/caller.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/process/core/caller.py b/process/core/caller.py index 953add544..c996ef189 100644 --- a/process/core/caller.py +++ b/process/core/caller.py @@ -35,11 +35,12 @@ def __init__(self, models: Models, data: DataStructure): variables are fully initialised with consistent values, the models are called with the initial optimisation parameters, x. - :param models: physics and engineering model objects - :type models: Models - :param data: data structure object to be passed on to the constraint - evaluators - :type data: DataStructure + Parameters + ---------- + models : + physics and engineering model objects + data : + data structure object to be passed on to the constraint evaluators """ self.models = models self.data = data From 924f11ae4632c26cc4614420a57962436bf07a3c Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:18:43 +0100 Subject: [PATCH 03/10] Refactor __init__ method docstring to use NumPy style for parameters Co-authored-by: Copilot --- process/core/log.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/process/core/log.py b/process/core/log.py index 22f73a582..891da1f94 100644 --- a/process/core/log.py +++ b/process/core/log.py @@ -19,11 +19,13 @@ class ProcessLogHandler(Handler): the handler or using the methods start_capturing/stop_capturing. """ - def __init__(self, capturing=True): - """Instantiates a ProcessLogHandler. + def __init__(self, capturing: bool = True): + """Instantiate a ProcessLogHandler. - :param capturing: capture and store emitted logs? - :type capturning: bool + Parameters + ---------- + capturing : + Whether to capture and store emitted logs, by default True """ super().__init__() self._logs = [] From eec6303296a5fa6ff01214e710fe2f8b8d94e60c Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:21:49 +0100 Subject: [PATCH 04/10] Refactor docstrings to use NumPy style for blanket module calculations Co-authored-by: Copilot --- process/models/blankets/blanket_library.py | 151 +++++++++++---------- 1 file changed, 79 insertions(+), 72 deletions(-) diff --git a/process/models/blankets/blanket_library.py b/process/models/blankets/blanket_library.py index 3f1cf646c..5713b73a1 100644 --- a/process/models/blankets/blanket_library.py +++ b/process/models/blankets/blanket_library.py @@ -1461,16 +1461,19 @@ def thermo_hydraulic_model_pressure_drop_calculations(self, output: bool): def calculate_dshaped_inboard_blkt_segment_poloidal( dz_blkt_half: float, n_blkt_inboard_modules_poloidal: int ) -> float: - """Calculations for D-shaped inboard blanket module poloidal segment length + """Calculate D-shaped inboard blanket module poloidal segment length. - :param dz_blkt_half: Half-height of the blanket module (m) - :type dz_blkt_half: float - :param n_blkt_inboard_modules_poloidal: Number of inboard blanket modules in poloidal direction - :type n_blkt_inboard_modules_poloidal: int - - :return: Segment length of inboard blanket module in poloidal direction (m) - :rtype: float + Parameters + ---------- + dz_blkt_half : + Half-height of the blanket module (m) + n_blkt_inboard_modules_poloidal : + Number of inboard blanket modules in poloidal direction + Returns + ------- + : + Segment length of inboard blanket module in poloidal direction (m) """ # D-shaped machine # Segment vertical inboard surface (m) @@ -1486,28 +1489,29 @@ def calculate_dshaped_outboard_blkt_segment_poloidal( n_divertors: int, f_ster_div_single: float, ) -> float: - """ - Calculations for D-shaped outboard blanket module poloidal segment length - - :param n_blkt_outboard_modules_poloidal: Number of outboard blanket modules in poloidal direction - :type n_blkt_outboard_modules_poloidal: int - :param dr_fw_plasma_gap_inboard: Radial gap between inboard first wall and plasma (m) - :type dr_fw_plasma_gap_inboard: float - :param rminor: Minor radius of the plasma (m) - :type rminor: float - :param dr_fw_plasma_gap_outboard: Radial gap between outboard first wall and plasma (m) - :type dr_fw_plasma_gap_outboard: float - :param dz_blkt_half: Half-height of the blanket module (m) - :type dz_blkt_half: float - :param n_divertors: Number of divertors (1 for single null, 2 for double null) - :type n_divertors: int - :param f_ster_div_single: Fractional poloidal length of the divertor in single null configuration - :type f_ster_div_single: float - - :return: Segment length of outboard blanket module in poloidal direction (m) - :rtype: float + """Calculate D-shaped outboard blanket module poloidal segment length. + Parameters + ---------- + n_blkt_outboard_modules_poloidal : + Number of outboard blanket modules in poloidal direction + dr_fw_plasma_gap_inboard : + Radial gap between inboard first wall and plasma (m) + rminor : + Minor radius of the plasma (m) + dr_fw_plasma_gap_outboard : + Radial gap between outboard first wall and plasma (m) + dz_blkt_half : + Half-height of the blanket module (m) + n_divertors : + Number of divertors (1 for single null, 2 for double null) + f_ster_div_single : + Fractional poloidal length of the divertor in single null configuration + Returns + ------- + : + Segment length of outboard blanket module in poloidal direction (m) """ # Calculate perimeter of ellipse that defines the internal # surface of the outboard first wall / blanket @@ -1550,29 +1554,31 @@ def calculate_elliptical_inboard_blkt_segment_poloidal( n_divertors: int, f_ster_div_single: float, ) -> float: - """ - Calculations for elliptical inboard blanket module poloidal segment length - - :param rmajor: Major radius of the plasma (m) - :type rmajor: float - :param rminor: Minor radius of the plasma (m) - :type rminor: float - :param triang: Triangularity of the plasma - :type triang: float - :param dr_fw_plasma_gap_inboard: Radial gap between inboard first wall and plasma (m) - :type dr_fw_plasma_gap_inboard: float - :param dz_blkt_half: Half-height of the blanket module (m) - :type dz_blkt_half: float - :param n_blkt_inboard_modules_poloidal: Number of inboard blanket modules in poloidal direction - :type n_blkt_inboard_modules_poloidal: int - :param n_divertors: Number of divertors (1 for single null, 2 for double null) - :type n_divertors: int - :param f_ster_div_single: Fractional poloidal length of the divertor in single null configuration - :type f_ster_div_single: float - - :return: Segment length of inboard blanket module in poloidal direction (m) - :rtype: float + """Calculate elliptical inboard blanket module poloidal segment length. + Parameters + ---------- + rmajor : + Major radius of the plasma (m) + rminor : + Minor radius of the plasma (m) + triang : + Triangularity of the plasma + dr_fw_plasma_gap_inboard : + Radial gap between inboard first wall and plasma (m) + dz_blkt_half : + Half-height of the blanket module (m) + n_blkt_inboard_modules_poloidal : + Number of inboard blanket modules in poloidal direction + n_divertors : + Number of divertors (1 for single null, 2 for double null) + f_ster_div_single : + Fractional poloidal length of the divertor in single null configuration + + Returns + ------- + : + Segment length of inboard blanket module in poloidal direction (m) """ # Major radius where half-ellipses 'meet' (m) r1 = rmajor - rminor * triang @@ -1617,30 +1623,31 @@ def calculate_elliptical_outboard_blkt_segment_poloidal( n_divertors: int, f_ster_div_single: float, ) -> float: - """ - Calculations for elliptical outboard blanket module poloidal segment length - - :param rmajor: Major radius of the plasma (m) - :type rmajor: float - :param rminor: Minor radius of the plasma (m) - :type rminor: float - :param triang: Triangularity of the plasma - :type triang: float - :param dz_blkt_half: Half-height of the blanket module (m) - :type dz_blkt_half: float - :param dr_fw_plasma_gap_outboard: Radial gap between outboard first wall and plasma (m) - :type dr_fw_plasma_gap_outboard: float - :param n_blkt_outboard_modules_poloidal: Number of outboard blanket modules in poloidal direction - :type n_blkt_outboard_modules_poloidal: int - :param n_divertors: Number of divertors (1 for single null, 2 for double null) - :type n_divertors: int - :param f_ster_div_single: Fractional poloidal length of the divertor in single null configuration - :type f_ster_div_single: float - - :return: Segment length of outboard blanket module in poloidal direction (m) - :rtype: float + """Calculate elliptical outboard blanket module poloidal segment length. + Parameters + ---------- + rmajor : + Major radius of the plasma (m) + rminor : + Minor radius of the plasma (m) + triang : + Triangularity of the plasma + dz_blkt_half : + Half-height of the blanket module (m) + dr_fw_plasma_gap_outboard : + Radial gap between outboard first wall and plasma (m) + n_blkt_outboard_modules_poloidal : + Number of outboard blanket modules in poloidal direction + n_divertors : + Number of divertors (1 for single null, 2 for double null) + f_ster_div_single : + Fractional poloidal length of the divertor in single null configuration + Returns + ------- + : + Segment length of outboard blanket module in poloidal direction (m) """ # Major radius where half-ellipses 'meet' (m) r1 = rmajor - rminor * triang From ef45f6afe6ac3c035673b453cd0e76b6c4d93efe Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:23:10 +0100 Subject: [PATCH 05/10] Refactor __init__ method of ImpurityRadiation class to use NumPy style docstring for parameters Co-authored-by: Copilot --- process/models/physics/impurity_radiation.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/process/models/physics/impurity_radiation.py b/process/models/physics/impurity_radiation.py index f33b314c6..7927ab1bb 100644 --- a/process/models/physics/impurity_radiation.py +++ b/process/models/physics/impurity_radiation.py @@ -11,6 +11,7 @@ from process.core import constants from process.core.exceptions import ProcessError, ProcessValueError from process.data_structure import impurity_radiation_module +from process.models.physics.plasma_profiles import PlasmaProfile logger = logging.getLogger(__name__) @@ -530,10 +531,13 @@ class ImpurityRadiation: element to find the total impurity radiation loss. """ - def __init__(self, plasma_profile): - """ - :param plasma_profile: Plasma profile class, parameterises the density and temperature profiles. - :type plasma_profile: Plasma profile class + def __init__(self, plasma_profile: PlasmaProfile): + """Initialize the ImpurityRadiation class. + + Parameters + ---------- + plasma_profile : + Parameterises the density and temperature profiles. """ self.plasma_profile = plasma_profile self.rho = plasma_profile.neprofile.profile_x From 395cad98115d78d402cb7e3a8bf93e07afb95619 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:26:46 +0100 Subject: [PATCH 06/10] Refactor docstring in PlasmaCurrent class to use NumPy style for parameters and return values Co-authored-by: Copilot --- process/models/physics/plasma_current.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/process/models/physics/plasma_current.py b/process/models/physics/plasma_current.py index 8be6efc82..318a782ed 100644 --- a/process/models/physics/plasma_current.py +++ b/process/models/physics/plasma_current.py @@ -569,17 +569,23 @@ def calculate_current_coefficient_peng( """ Calculate the plasma current scaling coefficient for the Peng scaling from the STAR code. - :param eps: Plasma inverse aspect ratio. - :type eps: float - :param len_plasma_poloidal: Plasma poloidal perimeter length [m]. - :type len_plasma_poloidal: float - :param rminor: Plasma minor radius [m]. - :type rminor: float + Parameters + ---------- + eps: + Plasma inverse aspect ratio. + len_plasma_poloidal: + Plasma poloidal perimeter length (m). + rminor: + Plasma minor radius (m). - :return: The plasma current scaling coefficient. - :rtype: float + Returns + ------- + : + The plasma current scaling coefficient. - :references: None + References + ---------- + None """ return ( (1.22 - 0.68 * eps) From 0740b72d0ac0bdae161b8dd7ed0bc8c245c976cc Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:28:10 +0100 Subject: [PATCH 07/10] Refactor __init__ method docstring in IFE class to use NumPy style for parameters Co-authored-by: Copilot --- process/models/ife.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/process/models/ife.py b/process/models/ife.py index c9384406a..3c5339566 100644 --- a/process/models/ife.py +++ b/process/models/ife.py @@ -45,10 +45,14 @@ class IFE(Model): def __init__(self, availability, costs): """Initialises the IFE module's variables - :param availability: a pointer to the availability model, allowing use of availability's variables/methods - :type availability: process.availability.Availability - :param costs: a pointer to the costs model, allowing the use of costs' variables/methods - :type costs: process.costs.Costs + Parameters + ---------- + availability : + A pointer to the availability model, allowing use of availability's + variables/methods + costs : + A pointer to the costs model, allowing the use of costs' + variables/methods """ self.outfile: int = constants.NOUT self.availability = availability From a808822d1035a9f5176003f4c21591f665046ddc Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:31:17 +0100 Subject: [PATCH 08/10] Refactor __init__ method docstring in Scan class to use NumPy style for parameters Co-authored-by: Copilot --- process/core/scan.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/process/core/scan.py b/process/core/scan.py index e8273f18e..326173eb2 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -10,6 +10,7 @@ from process.core.caller import write_output_files from process.core.exceptions import ProcessValueError from process.core.log import logging_model_handler, show_errors +from process.core.model import DataStructure from process.core.solver import constraints from process.core.solver.solver_handler import SolverHandler from process.data_structure import ( @@ -29,6 +30,7 @@ scan_variables, tfcoil_variables, ) +from process.main import Models logger = logging.getLogger(__name__) @@ -194,15 +196,17 @@ def _missing_(cls, var): class Scan: """Perform a parameter scan using the Fortran scan module.""" - def __init__(self, models, solver, data): + def __init__(self, models: Models, solver: str, data: DataStructure): """Immediately run the run_scan() method. - :param models: physics and engineering model objects - :type models: process.main.Models - :param solver: which solver to use, as specified in solver.py - :type solver: str - :param data: data structure object - :type data: DataStructure + Parameters + ---------- + models : + Physics and engineering model objects + solver : + Which solver to use, as specified in solver.py + data : + Data structure object """ self.models = models self.solver = solver From b4b75156c313e0d563f4c24643f65c4e799d2a38 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:32:55 +0100 Subject: [PATCH 09/10] Refactor __init__ method docstring in Evaluators class to use NumPy style for parameters Co-authored-by: Copilot --- process/core/scan.py | 3 +-- process/core/solver/evaluators.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/process/core/scan.py b/process/core/scan.py index 326173eb2..9e9e39ac4 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -30,7 +30,6 @@ scan_variables, tfcoil_variables, ) -from process.main import Models logger = logging.getLogger(__name__) @@ -196,7 +195,7 @@ def _missing_(cls, var): class Scan: """Perform a parameter scan using the Fortran scan module.""" - def __init__(self, models: Models, solver: str, data: DataStructure): + def __init__(self, models, solver: str, data: DataStructure): """Immediately run the run_scan() method. Parameters diff --git a/process/core/solver/evaluators.py b/process/core/solver/evaluators.py index 3b65f8325..dbef53e40 100644 --- a/process/core/solver/evaluators.py +++ b/process/core/solver/evaluators.py @@ -4,6 +4,7 @@ import numpy as np from process.core.caller import Caller +from process.core.model import DataStructure from process.data_structure import cost_variables as cv from process.data_structure import global_variables as gv from process.data_structure import numerics @@ -16,16 +17,17 @@ class Evaluators: """Calls models to evaluate function and gradient functions.""" - def __init__(self, models, data, _x): + def __init__(self, models, data: DataStructure, _x: np.ndarray): """Instantiate Caller with model objects. - :param models: physics and engineering model objects - :type models: process.main.Models - :param data: data structure object for providing constraint - data to the Caller - :type data: DataStructure - :param x: optimisation parameters - :type x: np.ndarray + Parameters + ---------- + models : + Physics and engineering model objects + data : + Data structure object for providing constraint data to the Caller + _x : + Optimisation parameters """ self.caller = Caller(models, data) From 32eb361912709e92e4774c800b9a03a88a6f457b Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 5 May 2026 12:25:41 +0100 Subject: [PATCH 10/10] Add Model type hint Co-authored-by: Copilot --- process/core/scan.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/process/core/scan.py b/process/core/scan.py index 9e9e39ac4..dfc0d645c 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -1,7 +1,10 @@ +from __future__ import annotations + import logging import time from dataclasses import astuple, dataclass from enum import Enum +from typing import TYPE_CHECKING import numpy as np from tabulate import tabulate @@ -10,7 +13,6 @@ from process.core.caller import write_output_files from process.core.exceptions import ProcessValueError from process.core.log import logging_model_handler, show_errors -from process.core.model import DataStructure from process.core.solver import constraints from process.core.solver.solver_handler import SolverHandler from process.data_structure import ( @@ -31,6 +33,9 @@ tfcoil_variables, ) +if TYPE_CHECKING: + from process.core.model import DataStructure, Model + logger = logging.getLogger(__name__) @@ -195,7 +200,7 @@ def _missing_(cls, var): class Scan: """Perform a parameter scan using the Fortran scan module.""" - def __init__(self, models, solver: str, data: DataStructure): + def __init__(self, models: Model, solver: str, data: DataStructure): """Immediately run the run_scan() method. Parameters