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 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 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 = [] diff --git a/process/core/scan.py b/process/core/scan.py index e8273f18e..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 @@ -30,6 +33,9 @@ tfcoil_variables, ) +if TYPE_CHECKING: + from process.core.model import DataStructure, Model + logger = logging.getLogger(__name__) @@ -194,15 +200,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: Model, 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 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) 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 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 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 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)