Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion process/core/io/vary_run/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ def setup(self):
)
data_structure.global_variables.fileprefix = str(self.wdir / self.infile)

def run_process(self, input_path: Path, solver: str = "vmcon"):
@staticmethod
def run_process(input_path: Path, solver: str = "vmcon"):
"""Perform a single run of PROCESS, catching any errors.

Parameters
Expand Down
9 changes: 6 additions & 3 deletions process/core/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ def post_optimise(self, ifail: int):
),
)

def verror(self, ifail: int):
@staticmethod
def verror(ifail: int):
"""Routine to print out relevant messages in the case of an
unfeasible result from a VMCON (optimisation) run

Expand Down Expand Up @@ -952,7 +953,8 @@ def scan_2d(self):
)
print(f"\nConvergence Percentage: {converged_percentage:.2f}%")

def scan_2d_init(self):
@staticmethod
def scan_2d_init():
process_output.ovarin(
constants.MFILE,
"Number of first variable scan points",
Expand Down Expand Up @@ -1051,7 +1053,8 @@ def scan_2d_write_point_header(self, iscan, iscan_1, iscan_2):

return iscan_r

def scan_1d_write_plot(self):
@staticmethod
def scan_1d_write_plot():
if scan_variables.first_call_1d:
process_output.ovarin(
constants.MFILE,
Expand Down
11 changes: 8 additions & 3 deletions process/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@
PlasmaBeta,
PlasmaInductance,
)
from process.models.physics.plasma_current import PlasmaCurrent, PlasmaDiamagneticCurrent
from process.models.physics.plasma_current import (
PlasmaCurrent,
PlasmaDiamagneticCurrent,
)
from process.models.physics.plasma_fields import PlasmaFields
from process.models.physics.plasma_geometry import PlasmaGeom
from process.models.physics.plasma_profiles import PlasmaProfile
Expand Down Expand Up @@ -444,11 +447,13 @@ def run_scan(self):
)
self.scan = Scan(self.models, self.solver, self.data)

def show_errors(self):
@staticmethod
def show_errors():
"""Report all informational/error messages encountered."""
show_errors(constants.NOUT)

def finish(self):
@staticmethod
def finish():
"""Run the finish subroutine to close files open in the Fortran.

Files being handled by Fortran must be closed before attempting to
Expand Down
15 changes: 6 additions & 9 deletions process/models/availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,9 @@ def calc_u_unplanned_divertor(self, output: bool) -> float:
# Integrating the instantaneous availability gives the mean
# availability over the planned cycle life N
if self.data.costs.div_nu <= self.data.costs.div_nref:
logger.error(
"""div_nu <= div_nref
logger.error("""div_nu <= div_nref
The cycle when the divertor fails with 100% probability <= & Reference value for cycle life of divertor
"""
)
""")
po.ocmmnt(
self.outfile,
"ERROR: The cycle when the divertor fails with 100% probability & <= Reference value for cycle cycle life of divertor",
Expand Down Expand Up @@ -895,11 +893,9 @@ def calc_u_unplanned_fwbs(self, output: bool) -> float:
)

if self.data.costs.fwbs_nu <= self.data.costs.fwbs_nref:
logger.error(
"""fwbs_nu <= fwbs_nref
logger.error("""fwbs_nu <= fwbs_nref
The cycle when the blanket fails with 100% probability <= &Reference value for cycle life of blanket
"""
)
""")
po.ocmmnt(
self.outfile,
"EROROR: The cycle when the blanket fails with 100% probability& <= Reference value for cycle life of blanket",
Expand Down Expand Up @@ -1029,7 +1025,8 @@ def calc_u_unplanned_bop(self, output: bool) -> float:

return u_unplanned_bop

def calc_u_unplanned_hcd(self) -> float:
@staticmethod
def calc_u_unplanned_hcd() -> float:
"""Calculates the unplanned unavailability of the heating and current drive system


Expand Down
9 changes: 5 additions & 4 deletions process/models/blankets/blanket_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -3239,8 +3239,8 @@ def pipe_hydraulic_diameter(self, i_channel_shape):
f"i_channel_shape ={i_channel_shape} is an invalid option."
)

@staticmethod
def elbow_coeff(
self,
radius_pipe_elbow: float,
deg_pipe_elbow: float,
darcy_friction: float,
Expand Down Expand Up @@ -3490,8 +3490,9 @@ def calculate_basic_geometry(self):
b_bz_liq=self.data.fwbs.b_bz_liq,
)

@staticmethod
def blkt_outboard_poloidal_plasma_angle(
self, n_divertors: int, deg_div_poloidal_plasma: float
n_divertors: int, deg_div_poloidal_plasma: float
) -> float:
"""Calculate the poloidal angle subtended by the outboard blanket at the
plasma mid-plane.
Expand Down Expand Up @@ -3571,8 +3572,8 @@ def calculate_blkt_outboard_poloidal_plasma_angle(
)
)

@staticmethod
def calculate_blanket_outboard_module_geometry(
self,
n_blkt_outboard_modules_toroidal: int,
rmajor: float,
rminor: float,
Expand Down Expand Up @@ -3647,8 +3648,8 @@ def calculate_blkt_inboard_poloidal_plasma_angle(
2.0 * np.arctan(dz_blkt_half / (rminor + dr_fw_plasma_gap_inboard))
)

@staticmethod
def calculate_blanket_inboard_module_geometry(
self,
n_blkt_inboard_modules_toroidal: int,
rmajor: float,
rminor: float,
Expand Down
10 changes: 6 additions & 4 deletions process/models/blankets/hcpb.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ def nuclear_heating_magnets(self, output: bool):
self.data.tfcoil.m_tf_coils_total,
)

@staticmethod
def nuclear_heating_fw(
self,
m_fw_total: float,
fw_armour_u_nuc_heating: float,
p_fusion_total_mw: float,
Expand Down Expand Up @@ -640,8 +640,9 @@ def nuclear_heating_fw(
)
return p_fw_nuclear_heat_total_mw

@staticmethod
def nuclear_heating_blanket(
self, m_blkt_total: float, p_fusion_total_mw: float
m_blkt_total: float, p_fusion_total_mw: float
) -> tuple[float, float]:
"""Calculates the nuclear heating in the blanket for the CCFE HCPB model.

Expand Down Expand Up @@ -685,8 +686,8 @@ def nuclear_heating_blanket(

return p_blkt_nuclear_heat_total_mw, exp_blanket

@staticmethod
def nuclear_heating_shield(
self,
itart: int,
dr_shld_outboard: float,
dr_shld_inboard: float,
Expand Down Expand Up @@ -988,7 +989,8 @@ def powerflow_calc(self, output: bool):
self.data.fwbs.radius_blkt_channel_180_bend,
)

def st_cp_angle_fraction(self, z_cp_top, r_cp_mid, r_cp_top, rmajor):
@staticmethod
def st_cp_angle_fraction(z_cp_top, r_cp_mid, r_cp_top, rmajor):
"""
Estimates the CP angular solid angle coverage fration
Equation (1-3) from
Expand Down
4 changes: 2 additions & 2 deletions process/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def run(self):
dx_beam_shield=self.data.current_drive.dx_beam_shield,
)

@staticmethod
def calculate_beam_port_size(
self,
f_radius_beam_tangency_rmajor: float,
rmajor: float,
n_tf_coils: int,
Expand Down Expand Up @@ -1458,8 +1458,8 @@ def divgeom(self, output: bool):
)
return divht

@staticmethod
def plasma_outboard_edge_toroidal_ripple(
self,
ripple_b_tf_plasma_edge_max: float,
r_tf_outboard_mid: float,
n_tf_coils: int,
Expand Down
6 changes: 4 additions & 2 deletions process/models/costs/costs_2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,15 +1236,17 @@ def calc_remaining_subsystems(self):
for j in range(35, 60):
self.data.costs_2015.s_cost[60] += self.data.costs_2015.s_cost[j]

def value_function(self, x):
@staticmethod
def value_function(x):
"""Value function
Function for separative work unit calculation for enrichment cost
PROCESS Costs Paper (M. Kovari, J. Morris)

"""
return (1.0e0 - 2.0e0 * x) * np.log((1.0e0 - x) / x)

def ocost(self, file, descr, vname, value):
@staticmethod
def ocost(file, descr, vname, value):
"""Routine to print out the code, description and value
of a cost item from array s in costs_2015

Expand Down
4 changes: 2 additions & 2 deletions process/models/divertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ def divwade(
)
return self.data.divertor.pflux_div_heat_load_mw

@staticmethod
def incident_radiation_power(
self,
p_plasma_rad_mw: float,
f_ster_div_single: float,
n_divertors: int,
Expand All @@ -396,8 +396,8 @@ def incident_radiation_power(
"""
return p_plasma_rad_mw * f_ster_div_single * n_divertors

@staticmethod
def incident_neutron_power(
self,
p_plasma_neutron_mw: float,
f_ster_div_single: float,
n_divertors: int,
Expand Down
9 changes: 6 additions & 3 deletions process/models/ife.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,8 @@ def ifephy(self, output: bool = False):
self.data.physics.pflux_fw_neutron_mw,
)

def driver(self, edrive, gainve, etave):
@staticmethod
def driver(edrive, gainve, etave):
"""Routine to calculate parameters of a generic driver
suitable for inertial fusion energy

Expand Down Expand Up @@ -1512,7 +1513,8 @@ def driver(self, edrive, gainve, etave):

return gain, etadrv

def lasdrv(self, edrive):
@staticmethod
def lasdrv(edrive):
"""Routine to calculate parameters of a laser driver
suitable for inertial fusion energy

Expand Down Expand Up @@ -1569,7 +1571,8 @@ def lasdrv(self, edrive):

return gain, etadrv

def iondrv(self, edrive):
@staticmethod
def iondrv(edrive):
"""Routine to calculate parameters of a heavy ion driver
suitable for inertial fusion energy

Expand Down
16 changes: 9 additions & 7 deletions process/models/pfcoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,8 @@ def tf_pf_collision_detector(self):
"One or more collision between TF and PF coils. Check PF placement."
)

def solv(self, n_pf_groups_max, n_pf_coil_groups, nrws, gmat, bvec):
@staticmethod
def solv(n_pf_groups_max, n_pf_coil_groups, nrws, gmat, bvec):
"""Solve a matrix using singular value decomposition.

This routine solves the matrix equation for calculating the
Expand Down Expand Up @@ -2876,7 +2877,8 @@ def outvolt(self):
* self.data.pf_coil.n_pf_coil_turns[k],
)

def selfinductance(self, a, b, c, n):
@staticmethod
def selfinductance(a, b, c, n):
"""Calculates the selfinductance using Bunet's formula.


Expand Down Expand Up @@ -2993,8 +2995,8 @@ def output(self):
def run(self):
"""This model doesn't need to be run"""

@staticmethod
def calculate_cs_geometry(
self,
z_tf_inside_half: float,
f_z_cs_tf_internal: float,
dr_cs: float,
Expand Down Expand Up @@ -3067,8 +3069,8 @@ def calculate_cs_geometry(
dr_cs_full,
)

@staticmethod
def calculate_cs_turn_geometry_eu_demo(
self,
a_cs_turn: float,
f_dr_dz_cs_turn: float,
radius_cs_turn_corners: float,
Expand Down Expand Up @@ -3145,8 +3147,8 @@ def calculate_cs_turn_geometry_eu_demo(
dz_cs_turn_conduit,
)

@staticmethod
def place_cs_filaments(
self,
n_cs_current_filaments: int,
r_cs_middle: float,
z_cs_inside_half: float,
Expand Down Expand Up @@ -3606,8 +3608,8 @@ def ohcalc(self):
)
self.calculate_cs_self_midplane_axial_stress_time_profile()

@staticmethod
def calculate_cs_self_peak_magnetic_field(
self,
j_cs: float,
r_cs_inner: float,
r_cs_outer: float,
Expand Down Expand Up @@ -3746,8 +3748,8 @@ def output_cs_structure(self):
"OP ",
)

@staticmethod
def calculate_cs_self_peak_midplane_axial_stress(
self,
r_cs_outer: float,
r_cs_inner: float,
dz_cs_half: float,
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dependencies = ["pre-commit", "ruff", "ty"]

[tool.hatch.envs.lint.scripts]
fmt = ["pre-commit run --all-files --hook-stage manual {args:}"]
fmt_extra = ["ruff check --select=E501,PLR6301,C901,PLR0904,PLR0911,PLR0912,PLR0913,PLR0914,PLR0915,PLR0916,PLR0917,PLR1702,D100,D101,D102,D103,DOC501,D404,DOC102,D104,D105,PLC1901,S307 {args:.}"]
fmt_extra = ["ruff check --select=E501,C901,PLR0904,PLR0911,PLR0912,PLR0913,PLR0914,PLR0915,PLR0916,PLR0917,PLR1702,D100,D101,D102,D103,DOC501,D404,DOC102,D104,D105,PLC1901,S307 {args:.}"]

[tool.coverage.report]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
Expand Down Expand Up @@ -165,7 +165,6 @@ max-locals = 17
"tests/**" = [
"ARG",
"PLR2004",
"PLR6301",
"PLR0904",
"PLC1901",
"S101",
Expand Down Expand Up @@ -237,7 +236,6 @@ ignore = [

# urgent removal remainder
"E501",
"PLR6301",
# complexity
"C901",
"PLR0904",
Expand Down
Loading
Loading