diff --git a/process/blanket_library.py b/process/blanket_library.py index f90c0f992..aa447c98f 100644 --- a/process/blanket_library.py +++ b/process/blanket_library.py @@ -55,26 +55,14 @@ def component_volumes(self): # Calculate half-height # Blanket blanket_library.dz_blkt_half = self.component_half_height(icomponent=0) - # Shield - blanket_library.dz_shld_half = self.component_half_height(icomponent=1) - # Vacuum Vessel - blanket_library.dz_vv_half = self.component_half_height(icomponent=2) # D-shaped blanket and shield if physics_variables.itart == 1 or fwbs_variables.i_fw_blkt_vv_shape == 1: - for icomponent in range(3): - self.dshaped_component(icomponent) + self.dshaped_component() # Elliptical blanket and shield else: - for icomponent in range(3): - self.elliptical_component(icomponent) - - # This will fail the hts_REBCO and 2D_scan regression tests, - # the number of VMCON iterations (nviter) is different. - # Seems to be because in the blanket calculations (icomponent=0): - # r2 = 1.3836567143743970 rather than old value of r2 = 1.3836567143743972, - # r3 = 3.7009701431231936 rather than r3 = 3.7009701431231923. + self.elliptical_component() # Apply coverage factors to volumes and surface areas self.apply_coverage_factors() @@ -94,22 +82,6 @@ def component_half_height(self, icomponent: int): + divertor_variables.dz_divertor - build_variables.dz_blkt_upper ) - # Sheild - elif icomponent == 1: - hbot = ( - build_variables.z_plasma_xpoint_lower - + build_variables.dz_xpoint_divertor - + divertor_variables.dz_divertor - ) - # Vacuum vessel - elif icomponent == 2: - hbot = ( - build_variables.z_tf_inside_half - - build_variables.dz_shld_vv_gap - - build_variables.dz_vv_lower - ) - else: - raise ProcessValueError(f"{icomponent=} is invalid, it must be either 0,1,2") # Calculate component internal upper half-height (m) # If a double null machine then symmetric @@ -123,19 +95,11 @@ def component_half_height(self, icomponent: int): + build_variables.dr_fw_inboard + build_variables.dr_fw_outboard ) - # Shield - if icomponent == 1: - htop = htop + build_variables.dz_blkt_upper - # Vacuum Vessel - if icomponent == 2: - htop = ( - htop + build_variables.dz_blkt_upper + build_variables.dz_shld_upper - ) # Average of top and bottom (m) return 0.5 * (htop + hbot) - def dshaped_component(self, icomponent: int): + def dshaped_component(self): """Calculate component surface area and volume using dshaped scheme Based on dshaped_blanket, dshaped_shield, dshaped_vv original author: J. Morris, CCFE, Culham Science Centre @@ -144,12 +108,10 @@ def dshaped_component(self, icomponent: int): # Calculate major radius to outer edge of inboard ... # ... section (m) r1 = build_variables.r_shld_inboard_inner - # ... shield (m) - if icomponent == 1: - r1 = r1 + build_variables.dr_shld_inboard + # ... blanket (m) - elif icomponent == 0: - r1 = r1 + build_variables.dr_shld_inboard + build_variables.dr_blkt_inboard + + r1 = r1 + build_variables.dr_shld_inboard + build_variables.dr_blkt_inboard # Horizontal distance between inside edges (m) # i.e. outer radius of inboard part to inner radius of outboard part @@ -161,69 +123,27 @@ def dshaped_component(self, icomponent: int): + build_variables.dr_fw_plasma_gap_outboard + build_variables.dr_fw_outboard ) - # Sheild - if icomponent == 1: - r2 = build_variables.dr_blkt_inboard + r2 + build_variables.dr_blkt_outboard - # Vaccum Vessel - if icomponent == 2: - r2 = build_variables.r_shld_outboard_outer - r1 - # Calculate surface area, assuming 100% coverage - if icomponent == 0: - ( - build_variables.a_blkt_inboard_surface, - build_variables.a_blkt_outboard_surface, - build_variables.a_blkt_total_surface, - ) = dshellarea(r1, r2, blanket_library.dz_blkt_half) - if icomponent == 1: - ( - build_variables.a_shld_inboard_surface, - build_variables.a_shld_outboard_surface, - build_variables.a_shld_total_surface, - ) = dshellarea(r1, r2, blanket_library.dz_shld_half) + ( + build_variables.a_blkt_inboard_surface, + build_variables.a_blkt_outboard_surface, + build_variables.a_blkt_total_surface, + ) = dshellarea(r1, r2, blanket_library.dz_blkt_half) - # Calculate volumes, assuming 100% coverage - if icomponent == 0: - ( - fwbs_variables.vol_blkt_inboard, - fwbs_variables.vol_blkt_outboard, - fwbs_variables.vol_blkt_total, - ) = dshellvol( - r1, - r2, - blanket_library.dz_blkt_half, - build_variables.dr_blkt_inboard, - build_variables.dr_blkt_outboard, - build_variables.dz_blkt_upper, - ) - elif icomponent == 1: - ( - blanket_library.vol_shld_inboard, - blanket_library.vol_shld_outboard, - fwbs_variables.vol_shld_total, - ) = dshellvol( - r1, - r2, - blanket_library.dz_shld_half, - build_variables.dr_shld_inboard, - build_variables.dr_shld_outboard, - build_variables.dz_shld_upper, - ) - elif icomponent == 2: - ( - blanket_library.vol_vv_inboard, - blanket_library.vol_vv_outboard, - fwbs_variables.vol_vv, - ) = dshellvol( - r1, - r2, - blanket_library.dz_vv_half, - build_variables.dr_vv_inboard, - build_variables.dr_vv_outboard, - (build_variables.dz_vv_upper + build_variables.dz_vv_lower) / 2, - ) - - def elliptical_component(self, icomponent: int): + ( + fwbs_variables.vol_blkt_inboard, + fwbs_variables.vol_blkt_outboard, + fwbs_variables.vol_blkt_total, + ) = dshellvol( + r1, + r2, + blanket_library.dz_blkt_half, + build_variables.dr_blkt_inboard, + build_variables.dr_blkt_outboard, + build_variables.dz_blkt_upper, + ) + + def elliptical_component(self): """Calculate component surface area and volume using elliptical scheme Based on elliptical_blanket, elliptical_shield, elliptical_vv original author: J. Morris, CCFE, Culham Science Centre @@ -239,80 +159,38 @@ def elliptical_component(self, icomponent: int): # Calculate distance between r1 and outer edge of inboard ... # ... section (m) r2 = r1 - build_variables.r_shld_inboard_inner - # ... shield (m) - if icomponent == 1: - r2 = r2 - build_variables.dr_shld_inboard - # ... blanket (m) - if icomponent == 0: - r2 = r2 - build_variables.dr_shld_inboard - build_variables.dr_blkt_inboard + + r2 = r2 - build_variables.dr_shld_inboard - build_variables.dr_blkt_inboard # Calculate distance between r1 and inner edge of outboard ... # ... section (m) r3 = build_variables.r_shld_outboard_outer - r1 - # ... shield (m) - if icomponent == 1: - r3 = r3 - build_variables.dr_shld_outboard - # ... blanket (m) - if icomponent == 0: - r3 = r3 - build_variables.dr_shld_outboard - build_variables.dr_blkt_outboard + + r3 = r3 - build_variables.dr_shld_outboard - build_variables.dr_blkt_outboard # Calculate surface area, assuming 100% coverage - if icomponent == 0: - ( - build_variables.a_blkt_inboard_surface, - build_variables.a_blkt_outboard_surface, - build_variables.a_blkt_total_surface, - ) = eshellarea(r1, r2, r3, blanket_library.dz_blkt_half) - if icomponent == 1: - ( - build_variables.a_shld_inboard_surface, - build_variables.a_shld_outboard_surface, - build_variables.a_shld_total_surface, - ) = eshellarea(r1, r2, r3, blanket_library.dz_shld_half) + + ( + build_variables.a_blkt_inboard_surface, + build_variables.a_blkt_outboard_surface, + build_variables.a_blkt_total_surface, + ) = eshellarea(r1, r2, r3, blanket_library.dz_blkt_half) # Calculate volumes, assuming 100% coverage - if icomponent == 0: - ( - fwbs_variables.vol_blkt_inboard, - fwbs_variables.vol_blkt_outboard, - fwbs_variables.vol_blkt_total, - ) = eshellvol( - r1, - r2, - r3, - blanket_library.dz_blkt_half, - build_variables.dr_blkt_inboard, - build_variables.dr_blkt_outboard, - build_variables.dz_blkt_upper, - ) - if icomponent == 1: - ( - blanket_library.vol_shld_inboard, - blanket_library.vol_shld_outboard, - fwbs_variables.vol_shld_total, - ) = eshellvol( - r1, - r2, - r3, - blanket_library.dz_shld_half, - build_variables.dr_shld_inboard, - build_variables.dr_shld_outboard, - build_variables.dz_shld_upper, - ) - if icomponent == 2: - ( - blanket_library.vol_vv_inboard, - blanket_library.vol_vv_outboard, - fwbs_variables.vol_vv, - ) = eshellvol( - r1, - r2, - r3, - blanket_library.dz_vv_half, - build_variables.dr_vv_inboard, - build_variables.dr_vv_outboard, - (build_variables.dz_vv_upper + build_variables.dz_vv_lower) / 2, - ) + + ( + fwbs_variables.vol_blkt_inboard, + fwbs_variables.vol_blkt_outboard, + fwbs_variables.vol_blkt_total, + ) = eshellvol( + r1, + r2, + r3, + blanket_library.dz_blkt_half, + build_variables.dr_blkt_inboard, + build_variables.dr_blkt_outboard, + build_variables.dz_blkt_upper, + ) def apply_coverage_factors(self): """Apply coverage factors to volumes @@ -361,33 +239,6 @@ def apply_coverage_factors(self): fwbs_variables.vol_blkt_inboard + fwbs_variables.vol_blkt_outboard ) - # Apply shield coverage factors - build_variables.a_shld_inboard_surface = ( - fwbs_variables.fvolsi * build_variables.a_shld_inboard_surface - ) - build_variables.a_shld_outboard_surface = ( - fwbs_variables.fvolso * build_variables.a_shld_outboard_surface - ) - build_variables.a_shld_total_surface = ( - build_variables.a_shld_inboard_surface - + build_variables.a_shld_outboard_surface - ) - - blanket_library.vol_shld_inboard = ( - fwbs_variables.fvolsi * blanket_library.vol_shld_inboard - ) - blanket_library.vol_shld_outboard = ( - fwbs_variables.fvolso * blanket_library.vol_shld_outboard - ) - fwbs_variables.vol_shld_total = ( - blanket_library.vol_shld_inboard + blanket_library.vol_shld_outboard - ) - - # Apply vacuum vessel coverage factor - # moved from dshaped_* and elliptical_* to keep coverage factor - # changes in the same location. - fwbs_variables.vol_vv = fwbs_variables.fvoldw * fwbs_variables.vol_vv - def primary_coolant_properties(self, output: bool): """Calculates the fluid properties of the Primary Coolant in the FW and BZ. Uses middle value of input and output temperatures of coolant. diff --git a/process/caller.py b/process/caller.py index 0a93243a1..7ed29c668 100644 --- a/process/caller.py +++ b/process/caller.py @@ -276,6 +276,10 @@ def _call_models_once(self, xc: np.ndarray) -> None: # First wall model self.models.fw.run() + self.models.shield.run() + + self.models.vacuum_vessel.run() + # Blanket model """Blanket switch values No. | model diff --git a/process/cryostat.py b/process/cryostat.py index ab4951d82..754ae6d5a 100644 --- a/process/cryostat.py +++ b/process/cryostat.py @@ -80,9 +80,6 @@ def external_cryo_geometry() -> None: * (build_variables.dr_cryostat + fwbs_variables.z_cryostat_half_inside) ) - (fwbs_variables.vol_cryostat_internal) - # Vacuum vessel mass (kg) - fwbs_variables.m_vv = fwbs_variables.vol_vv * fwbs_variables.den_steel - # Sum of internal vacuum vessel and cryostat masses (kg) fwbs_variables.dewmkg = ( fwbs_variables.vol_vv + fwbs_variables.vol_cryostat diff --git a/process/main.py b/process/main.py index 367fe51a7..9dc607dfb 100644 --- a/process/main.py +++ b/process/main.py @@ -101,11 +101,12 @@ from process.pulse import Pulse from process.resistive_tf_coil import AluminiumTFCoil, CopperTFCoil, ResistiveTFCoil from process.scan import Scan +from process.shield import Shield from process.stellarator import Neoclassics, Stellarator from process.structure import Structure from process.superconducting_tf_coil import SuperconductingTFCoil from process.tf_coil import TFCoil -from process.vacuum import Vacuum +from process.vacuum import Vacuum, VacuumVessel from process.water_use import WaterUse os.environ["PYTHON_PROCESS_ROOT"] = os.path.join(os.path.dirname(__file__)) @@ -664,8 +665,10 @@ def __init__(self): self.availability = Availability() self.buildings = Buildings() self.vacuum = Vacuum() + self.vacuum_vessel = VacuumVessel() self.water_use = WaterUse() self.pulse = Pulse() + self.shield = Shield() self.ife = IFE(availability=self.availability, costs=self.costs) self.plasma_profile = PlasmaProfile() self.fw = Fw() diff --git a/process/shield.py b/process/shield.py new file mode 100644 index 000000000..d012282f5 --- /dev/null +++ b/process/shield.py @@ -0,0 +1,303 @@ +import logging + +from process.blanket_library import dshellarea, dshellvol, eshellarea, eshellvol +from process.data_structure import blanket_library as blanket_library +from process.data_structure import build_variables as build_variables +from process.data_structure import ccfe_hcpb_module as ccfe_hcpb_module +from process.data_structure import divertor_variables as divertor_variables +from process.data_structure import fwbs_variables as fwbs_variables +from process.data_structure import physics_variables as physics_variables + +logger = logging.getLogger(__name__) + + +class Shield: + def __init__(self) -> None: + pass + + def run(self) -> None: + blanket_library.dz_shld_half = self.calculate_shield_half_height( + z_plasma_xpoint_lower=build_variables.z_plasma_xpoint_lower, + dz_xpoint_divertor=build_variables.dz_xpoint_divertor, + dz_divertor=divertor_variables.dz_divertor, + n_divertors=divertor_variables.n_divertors, + z_plasma_xpoint_upper=build_variables.z_plasma_xpoint_upper, + dr_fw_plasma_gap_inboard=build_variables.dr_fw_plasma_gap_inboard, + dr_fw_plasma_gap_outboard=build_variables.dr_fw_plasma_gap_outboard, + dr_fw_inboard=build_variables.dr_fw_inboard, + dr_fw_outboard=build_variables.dr_fw_outboard, + dz_blkt_upper=build_variables.dz_blkt_upper, + ) + # D-shaped blanket and shield + if physics_variables.itart == 1 or fwbs_variables.i_fw_blkt_vv_shape == 1: + ( + build_variables.a_shld_inboard_surface, + build_variables.a_shld_outboard_surface, + build_variables.a_shld_total_surface, + ) = self.calculate_dshaped_shield_areas( + r_shld_inboard_inner=build_variables.r_shld_inboard_inner, + dr_shld_inboard=build_variables.dr_shld_inboard, + dr_fw_inboard=build_variables.dr_fw_inboard, + dr_fw_plasma_gap_inboard=build_variables.dr_fw_plasma_gap_inboard, + rminor=physics_variables.rminor, + dr_fw_plasma_gap_outboard=build_variables.dr_fw_plasma_gap_outboard, + dr_fw_outboard=build_variables.dr_fw_outboard, + dr_blkt_inboard=build_variables.dr_blkt_inboard, + dr_blkt_outboard=build_variables.dr_blkt_outboard, + dz_shld_half=blanket_library.dz_shld_half, + ) + + ( + blanket_library.vol_shld_inboard, + blanket_library.vol_shld_outboard, + fwbs_variables.vol_shld_total, + ) = self.calculate_dshaped_shield_volumes( + r_shld_inboard_inner=build_variables.r_shld_inboard_inner, + dr_shld_inboard=build_variables.dr_shld_inboard, + dr_fw_inboard=build_variables.dr_fw_inboard, + dr_fw_plasma_gap_inboard=build_variables.dr_fw_plasma_gap_inboard, + rminor=physics_variables.rminor, + dr_fw_plasma_gap_outboard=build_variables.dr_fw_plasma_gap_outboard, + dr_fw_outboard=build_variables.dr_fw_outboard, + dr_blkt_inboard=build_variables.dr_blkt_inboard, + dr_blkt_outboard=build_variables.dr_blkt_outboard, + dz_shld_half=blanket_library.dz_shld_half, + dr_shld_outboard=build_variables.dr_shld_outboard, + dz_shld_upper=build_variables.dz_shld_upper, + ) + + else: + ( + build_variables.a_shld_inboard_surface, + build_variables.a_shld_outboard_surface, + build_variables.a_shld_total_surface, + ) = self.calculate_elliptical_shield_areas( + r_shld_inboard_inner=build_variables.r_shld_inboard_inner, + r_shld_outboard_outer=build_variables.r_shld_outboard_outer, + rmajor=physics_variables.rmajor, + triang=physics_variables.triang, + dr_shld_inboard=build_variables.dr_shld_inboard, + rminor=physics_variables.rminor, + dz_shld_half=blanket_library.dz_shld_half, + dr_shld_outboard=build_variables.dr_shld_outboard, + ) + + ( + blanket_library.vol_shld_inboard, + blanket_library.vol_shld_outboard, + fwbs_variables.vol_shld_total, + ) = self.calculate_elliptical_shield_volumes( + r_shld_inboard_inner=build_variables.r_shld_inboard_inner, + r_shld_outboard_outer=build_variables.r_shld_outboard_outer, + rmajor=physics_variables.rmajor, + triang=physics_variables.triang, + dr_shld_inboard=build_variables.dr_shld_inboard, + rminor=physics_variables.rminor, + dz_shld_half=blanket_library.dz_shld_half, + dr_shld_outboard=build_variables.dr_shld_outboard, + dz_shld_upper=build_variables.dz_shld_upper, + ) + + # Apply shield coverage factors + build_variables.a_shld_inboard_surface = ( + fwbs_variables.fvolsi * build_variables.a_shld_inboard_surface + ) + build_variables.a_shld_outboard_surface = ( + fwbs_variables.fvolso * build_variables.a_shld_outboard_surface + ) + build_variables.a_shld_total_surface = ( + build_variables.a_shld_inboard_surface + + build_variables.a_shld_outboard_surface + ) + + blanket_library.vol_shld_inboard = ( + fwbs_variables.fvolsi * blanket_library.vol_shld_inboard + ) + blanket_library.vol_shld_outboard = ( + fwbs_variables.fvolso * blanket_library.vol_shld_outboard + ) + fwbs_variables.vol_shld_total = ( + blanket_library.vol_shld_inboard + blanket_library.vol_shld_outboard + ) + + @staticmethod + def calculate_shield_half_height( + z_plasma_xpoint_lower: float, + dz_xpoint_divertor: float, + dz_divertor: float, + n_divertors: int, + z_plasma_xpoint_upper: float, + dr_fw_plasma_gap_inboard: float, + dr_fw_plasma_gap_outboard: float, + dr_fw_inboard: float, + dr_fw_outboard: float, + dz_blkt_upper: float, + ) -> float: + """Calculate shield half-height.""" + + z_bottom = z_plasma_xpoint_lower + dz_xpoint_divertor + dz_divertor + + # Calculate component internal upper half-height (m) + # If a double null machine then symmetric + if n_divertors == 2: + z_top = z_bottom + else: + z_top = z_plasma_xpoint_upper + 0.5 * ( + dr_fw_plasma_gap_inboard + + dr_fw_plasma_gap_outboard + + dr_fw_inboard + + dr_fw_outboard + ) + + z_top = z_top + dz_blkt_upper + + # Average of top and bottom (m) + return 0.5 * (z_top + z_bottom) + + @staticmethod + def calculate_dshaped_shield_volumes( + r_shld_inboard_inner: float, + dr_shld_inboard: float, + dr_fw_inboard: float, + dr_fw_plasma_gap_inboard: float, + rminor: float, + dr_fw_plasma_gap_outboard: float, + dr_fw_outboard: float, + dr_blkt_inboard: float, + dr_blkt_outboard: float, + dz_shld_half: float, + dr_shld_outboard: float, + dz_shld_upper: float, + ) -> tuple[float, float, float]: + """Calculate volumes of D-shaped shield segments.""" + + r_1 = r_shld_inboard_inner + dr_shld_inboard + r_2 = ( + dr_fw_inboard + + dr_fw_plasma_gap_inboard + + 2.0 * rminor + + dr_fw_plasma_gap_outboard + + dr_fw_outboard + ) + + r_2 = dr_blkt_inboard + r_2 + dr_blkt_outboard + + ( + vol_shld_inboard, + vol_shld_outboard, + vol_shld_total, + ) = dshellvol( + rmajor=r_1, + rminor=r_2, + zminor=dz_shld_half, + drin=dr_shld_inboard, + drout=dr_shld_outboard, + dz=dz_shld_upper, + ) + + return vol_shld_inboard, vol_shld_outboard, vol_shld_total + + @staticmethod + def calculate_dshaped_shield_areas( + r_shld_inboard_inner: float, + dr_shld_inboard: float, + dr_fw_inboard: float, + dr_fw_plasma_gap_inboard: float, + rminor: float, + dr_fw_plasma_gap_outboard: float, + dr_fw_outboard: float, + dr_blkt_inboard: float, + dr_blkt_outboard: float, + dz_shld_half: float, + ) -> tuple[float, float, float]: + """Calculate areas of D-shaped shield segments.""" + + r_1 = r_shld_inboard_inner + dr_shld_inboard + r_2 = ( + dr_fw_inboard + + dr_fw_plasma_gap_inboard + + 2.0 * rminor + + dr_fw_plasma_gap_outboard + + dr_fw_outboard + ) + + r_2 = dr_blkt_inboard + r_2 + dr_blkt_outboard + + ( + a_shld_inboard_surface, + a_shld_outboard_surface, + a_shld_total_surface, + ) = dshellarea(rmajor=r_1, rminor=r_2, zminor=dz_shld_half) + + return a_shld_inboard_surface, a_shld_outboard_surface, a_shld_total_surface + + @staticmethod + def calculate_elliptical_shield_volumes( + r_shld_inboard_inner: float, + r_shld_outboard_outer: float, + rmajor: float, + triang: float, + dr_shld_inboard: float, + rminor: float, + dz_shld_half: float, + dr_shld_outboard: float, + dz_shld_upper: float, + ) -> tuple[float, float, float]: + """Calculate volumes of elliptical shield segments.""" + + # Major radius to centre of inboard and outboard ellipses (m) + # (coincident in radius with top of plasma) + r_1 = rmajor - rminor * triang + r_2 = r_1 - r_shld_inboard_inner + + r_2 = r_2 - dr_shld_inboard + + r_3 = r_shld_outboard_outer - r_1 + r_3 = r_3 - dr_shld_outboard + + ( + vol_shld_inboard, + vol_shld_outboard, + vol_shld_total, + ) = eshellvol( + rshell=r_1, + rmini=r_2, + rmino=r_3, + zminor=dz_shld_half, + drin=dr_shld_inboard, + drout=dr_shld_outboard, + dz=dz_shld_upper, + ) + + return vol_shld_inboard, vol_shld_outboard, vol_shld_total + + @staticmethod + def calculate_elliptical_shield_areas( + r_shld_inboard_inner: float, + r_shld_outboard_outer: float, + rmajor: float, + triang: float, + dr_shld_inboard: float, + rminor: float, + dz_shld_half: float, + dr_shld_outboard: float, + ) -> tuple[float, float, float]: + """Calculate areas of elliptical shield segments.""" + + # Major radius to centre of inboard and outboard ellipses (m) + # (coincident in radius with top of plasma) + r_1 = rmajor - rminor * triang + r_2 = r_1 - r_shld_inboard_inner + + r_2 = r_2 - dr_shld_inboard + + r_3 = r_shld_outboard_outer - r_1 + r_3 = r_3 - dr_shld_outboard + + ( + a_shld_inboard_surface, + a_shld_outboard_surface, + a_shld_total_surface, + ) = eshellarea(rshell=r_1, rmini=r_2, rmino=r_3, zminor=dz_shld_half) + + return a_shld_inboard_surface, a_shld_outboard_surface, a_shld_total_surface diff --git a/process/vacuum.py b/process/vacuum.py index 13d545212..4c452ea0f 100644 --- a/process/vacuum.py +++ b/process/vacuum.py @@ -3,14 +3,18 @@ import numpy as np -from process import constants -from process import process_output as po -from process.data_structure import build_variables as buv -from process.data_structure import divertor_variables as dv -from process.data_structure import physics_variables as pv -from process.data_structure import tfcoil_variables as tfv -from process.data_structure import times_variables as tv -from process.data_structure import vacuum_variables as vacv +from process import constants, process_output +from process.blanket_library import dshellvol, eshellvol +from process.data_structure import ( + blanket_library, + build_variables, + divertor_variables, + fwbs_variables, + physics_variables, + tfcoil_variables, + times_variables, + vacuum_variables, +) logger = logging.getLogger(__name__) @@ -44,47 +48,56 @@ def run(self, output: bool) -> None: # MDK Check this!! gasld = ( - 2.0e0 * pv.molflow_plasma_fuelling_required * pv.m_fuel_amu * constants.UMASS + 2.0e0 + * physics_variables.molflow_plasma_fuelling_required + * physics_variables.m_fuel_amu + * constants.UMASS ) - self.i_vacuum_pumping = vacv.i_vacuum_pumping + self.i_vacuum_pumping = vacuum_variables.i_vacuum_pumping # i_vacuum_pumping required to be compared to a b string # as this is what f2py returns if self.i_vacuum_pumping == "old": ( pumpn, - vacv.n_vv_vacuum_ducts, - vacv.dlscal, - vacv.m_vv_vacuum_duct_shield, - vacv.dia_vv_vacuum_ducts, + vacuum_variables.n_vv_vacuum_ducts, + vacuum_variables.dlscal, + vacuum_variables.m_vv_vacuum_duct_shield, + vacuum_variables.dia_vv_vacuum_ducts, ) = self.vacuum( - pv.p_fusion_total_mw, - pv.rmajor, - pv.rminor, - 0.5e0 * (buv.dr_fw_plasma_gap_inboard + buv.dr_fw_plasma_gap_outboard), - pv.a_plasma_surface, - pv.vol_plasma, - buv.dr_shld_outboard, - buv.dr_shld_inboard, - buv.dr_tf_inboard, - buv.r_shld_inboard_inner - - buv.dr_shld_vv_gap_inboard - - buv.dr_vv_inboard, - tfv.n_tf_coils, - tv.t_plant_pulse_dwell, - pv.nd_plasma_electrons_vol_avg, - dv.n_divertors, + physics_variables.p_fusion_total_mw, + physics_variables.rmajor, + physics_variables.rminor, + 0.5e0 + * ( + build_variables.dr_fw_plasma_gap_inboard + + build_variables.dr_fw_plasma_gap_outboard + ), + physics_variables.a_plasma_surface, + physics_variables.vol_plasma, + build_variables.dr_shld_outboard, + build_variables.dr_shld_inboard, + build_variables.dr_tf_inboard, + build_variables.r_shld_inboard_inner + - build_variables.dr_shld_vv_gap_inboard + - build_variables.dr_vv_inboard, + tfcoil_variables.n_tf_coils, + times_variables.t_plant_pulse_dwell, + physics_variables.nd_plasma_electrons_vol_avg, + divertor_variables.n_divertors, qtorus, gasld, output=output, ) # MDK pumpn is real: convert to integer by rounding. - vacv.n_vac_pumps_high = math.floor(pumpn + 0.5e0) + vacuum_variables.n_vac_pumps_high = math.floor(pumpn + 0.5e0) elif self.i_vacuum_pumping == "simple": - vacv.n_iter_vacuum_pumps = self.vacuum_simple(output=output) + vacuum_variables.n_iter_vacuum_pumps = self.vacuum_simple(output=output) else: - logger.error(f"i_vacuum_pumping is invalid: {vacv.i_vacuum_pumping}") + logger.error( + f"i_vacuum_pumping is invalid: {vacuum_variables.i_vacuum_pumping}" + ) def vacuum_simple(self, output) -> float: """Simple model of vacuum pumping system @@ -101,24 +114,27 @@ def vacuum_simple(self, output) -> float: # One ITER torus cryopump has a throughput of 50 Pa m3/s = 1.2155e+22 molecules/s # Issue #304 n_iter_vacuum_pumps = ( - pv.molflow_plasma_fuelling_required / vacv.molflow_vac_pumps + physics_variables.molflow_plasma_fuelling_required + / vacuum_variables.molflow_vac_pumps ) # Pump-down: # Pumping speed per pump m3/s pumpspeed = ( - vacv.volflow_vac_pumps_max - * vacv.f_a_vac_pump_port_plasma_surface - * vacv.f_volflow_vac_pumps_impedance - * pv.a_plasma_surface - / tfv.n_tf_coils + vacuum_variables.volflow_vac_pumps_max + * vacuum_variables.f_a_vac_pump_port_plasma_surface + * vacuum_variables.f_volflow_vac_pumps_impedance + * physics_variables.a_plasma_surface + / tfcoil_variables.n_tf_coils ) - wallarea = (pv.a_plasma_surface / 1084.0e0) * 2000.0e0 + wallarea = (physics_variables.a_plasma_surface / 1084.0e0) * 2000.0e0 # Required pumping speed for pump-down pumpdownspeed = ( - vacv.outgasfactor * wallarea / vacv.pres_vv_chamber_base - ) * tv.t_plant_pulse_dwell ** (-vacv.outgasindex) + vacuum_variables.outgasfactor + * wallarea + / vacuum_variables.pres_vv_chamber_base + ) * times_variables.t_plant_pulse_dwell ** (-vacuum_variables.outgasindex) # Number of pumps required for pump-down npumpdown = pumpdownspeed / pumpspeed @@ -128,32 +144,32 @@ def vacuum_simple(self, output) -> float: # Output section if output: - po.oheadr(self.outfile, "Vacuum System") - po.ovarst( + process_output.oheadr(self.outfile, "Vacuum System") + process_output.ovarst( self.outfile, "Switch for vacuum pumping model", "(i_vacuum_pumping)", '"' + self.i_vacuum_pumping + '"', ) - po.ocmmnt( + process_output.ocmmnt( self.outfile, "Simple steady-state model with comparison to ITER cryopumps", ) - po.ovarre( + process_output.ovarre( self.outfile, "Plasma fuelling rate (nucleus-pairs/s)", "(molflow_plasma_fuelling_required)", - pv.molflow_plasma_fuelling_required, + physics_variables.molflow_plasma_fuelling_required, "OP ", ) - po.ocmmnt( + process_output.ocmmnt( self.outfile, "Number of high vacuum pumps, each with the throughput" ) - po.ocmmnt( + process_output.ocmmnt( self.outfile, " of one ITER cryopump (50 Pa m3 s-1 = 1.2e+22 molecules/s),", ) - po.ovarre( + process_output.ovarre( self.outfile, " all operating at the same time", "(n_iter_vacuum_pumps)", @@ -161,20 +177,20 @@ def vacuum_simple(self, output) -> float: "OP ", ) - po.ovarre( + process_output.ovarre( self.outfile, "Dwell time", "(t_plant_pulse_dwell)", - tv.t_plant_pulse_dwell, + times_variables.t_plant_pulse_dwell, ) - po.ovarre( + process_output.ovarre( self.outfile, "Number of pumps required for pump-down", "(npumpdown)", npumpdown, "OP ", ) - po.ovarre( + process_output.ovarre( self.outfile, "Number of pumps required overall", "(npump)", @@ -311,7 +327,7 @@ def vacuum( # nitrogen, DT, helium, DT again sp = ( [1.95, 1.8, 1.8, 1.8] - if vacv.i_vacuum_pump_type == 0 + if vacuum_variables.i_vacuum_pump_type == 0 else [9.0, 25.0, 5.0, 25.0] ) @@ -329,8 +345,8 @@ def vacuum( area = plasma_sarea * (aw + dsol) / aw - ogas = vacv.outgrat_fw * area * 10.0e0 # Outgassing rate (Pa-m^3/s) - s.append(ogas / vacv.pres_vv_chamber_base) + ogas = vacuum_variables.outgrat_fw * area * 10.0e0 # Outgassing rate (Pa-m^3/s) + s.append(ogas / vacuum_variables.pres_vv_chamber_base) # Pumpdown between burns # s(2) = net pump speed (DT) required for pumpdown between burns (m^3/s) @@ -338,7 +354,7 @@ def vacuum( # t_plant_pulse_dwell = dwell time between burns (s) pend = ( - 0.5e0 * nplasma * k * vacv.temp_vv_chamber_gas_burn_end + 0.5e0 * nplasma * k * vacuum_variables.temp_vv_chamber_gas_burn_end ) # pressure in plasma chamber after burn (Pa) pstart = 0.01e0 * pend # pressure in chamber before start of burn (Pa) @@ -349,10 +365,10 @@ def vacuum( volume = plasma_vol * (aw + dsol) * (aw + dsol) / (aw * aw) # dwell pumping options - if (vacv.i_vac_pump_dwell == 1) or (t_plant_pulse_dwell == 0): - tpump = tv.t_plant_pulse_coil_precharge - elif vacv.i_vac_pump_dwell == 2: - tpump = t_plant_pulse_dwell + tv.t_plant_pulse_coil_precharge + if (vacuum_variables.i_vac_pump_dwell == 1) or (t_plant_pulse_dwell == 0): + tpump = times_variables.t_plant_pulse_coil_precharge + elif vacuum_variables.i_vac_pump_dwell == 2: + tpump = t_plant_pulse_dwell + times_variables.t_plant_pulse_coil_precharge else: tpump = t_plant_pulse_dwell @@ -368,12 +384,12 @@ def vacuum( fhe = source / (frate * 4.985e5) s.extend( ( - (source / vacv.pres_div_chamber_burn / fhe), + (source / vacuum_variables.pres_div_chamber_burn / fhe), # Removal of dt on steady state basis # s(4) = net speed (D-T) required to remove dt at fuelling rate (m^3/s) ( (frate * 4.985e5 - source) - / (vacv.pres_div_chamber_burn * (1.0e0 - fhe)) + / (vacuum_variables.pres_div_chamber_burn * (1.0e0 - fhe)) ), ), ) @@ -463,7 +479,7 @@ def vacuum( else: logger.error( - f"Newton's method not converging; check fusion power, te {pv.p_fusion_total_mw=} {pv.temp_plasma_electron_vol_avg_kev=}" + f"Newton's method not converging; check fusion power, te {physics_variables.p_fusion_total_mw=} {physics_variables.temp_plasma_electron_vol_avg_kev=}" ) theta = math.pi / ntf @@ -507,7 +523,7 @@ def vacuum( # If cryopumps are used then an additional pump is required # for continuous operation with regeneration. - if vacv.i_vacuum_pump_type == 1: + if vacuum_variables.i_vacuum_pump_type == 1: pumpn = pumpn * 2.0e0 # Information for costing routine @@ -526,29 +542,29 @@ def vacuum( if output: # Output section - po.oheadr(self.outfile, "Vacuum System") + process_output.oheadr(self.outfile, "Vacuum System") - po.ocmmnt(self.outfile, "Pumpdown to Base Pressure :") - po.oblnkl(self.outfile) - po.ovarre( + process_output.ocmmnt(self.outfile, "Pumpdown to Base Pressure :") + process_output.oblnkl(self.outfile) + process_output.ovarre( self.outfile, "First wall outgassing rate (Pa m/s)", "(outgrat_fw)", - vacv.outgrat_fw, + vacuum_variables.outgrat_fw, ) - po.ovarre( + process_output.ovarre( self.outfile, "Total outgassing load (Pa m3/s)", "(ogas)", ogas, "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "Base pressure required (Pa)", "(pres_vv_chamber_base)", - vacv.pres_vv_chamber_base, + vacuum_variables.pres_vv_chamber_base, ) - po.ovarre( + process_output.ovarre( self.outfile, "Required N2 pump speed (m3/s)", "(s(1))", s[0], "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "N2 pump speed provided (m3/s)", "(snet(1))", @@ -556,44 +572,44 @@ def vacuum( "OP ", ) - po.osubhd(self.outfile, "Pumpdown between Burns :") - po.ovarre( + process_output.osubhd(self.outfile, "Pumpdown between Burns :") + process_output.ovarre( self.outfile, "Plasma chamber volume (m3)", "(volume)", volume, "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "Chamber pressure after burn (Pa)", "(pend)", pend, "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "Chamber pressure before burn (Pa)", "(pstart)", pstart ) - po.ovarin( + process_output.ovarin( self.outfile, "Allowable pumping time switch", "(i_vac_pump_dwell)", - vacv.i_vac_pump_dwell, + vacuum_variables.i_vac_pump_dwell, ) - po.ovarre( + process_output.ovarre( self.outfile, "Dwell time between burns (s)", "(t_plant_pulse_dwell.)", t_plant_pulse_dwell, ) - po.ovarre( + process_output.ovarre( self.outfile, "CS ramp-up time burns (s)", "(t_plant_pulse_coil_precharge.)", - tv.t_plant_pulse_coil_precharge, + times_variables.t_plant_pulse_coil_precharge, ) - po.ovarre( + process_output.ovarre( self.outfile, "Allowable pumping time between burns (s)", "(tpump)", tpump, ) - po.ovarre( + process_output.ovarre( self.outfile, "Required D-T pump speed (m3/s)", "(s(2))", s[1], "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "D-T pump speed provided (m3/s)", "(snet(2))", @@ -601,24 +617,24 @@ def vacuum( "OP ", ) - po.osubhd(self.outfile, "Helium Ash Removal :") - po.ovarre( + process_output.osubhd(self.outfile, "Helium Ash Removal :") + process_output.ovarre( self.outfile, "Divertor chamber gas pressure (Pa)", "(pres_div_chamber_burn)", - vacv.pres_div_chamber_burn, + vacuum_variables.pres_div_chamber_burn, ) - po.ovarre( + process_output.ovarre( self.outfile, "Helium gas fraction in divertor chamber", "(fhe)", fhe, "OP ", ) - po.ovarre( + process_output.ovarre( self.outfile, "Required helium pump speed (m3/s)", "(s(3))", s[2], "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "Helium pump speed provided (m3/s)", "(snet(3))", @@ -626,12 +642,14 @@ def vacuum( "OP ", ) - po.osubhd(self.outfile, "D-T Removal at Fuelling Rate :") - po.ovarre(self.outfile, "D-T fuelling rate (kg/s)", "(frate)", frate, "OP ") - po.ovarre( + process_output.osubhd(self.outfile, "D-T Removal at Fuelling Rate :") + process_output.ovarre( + self.outfile, "D-T fuelling rate (kg/s)", "(frate)", frate, "OP " + ) + process_output.ovarre( self.outfile, "Required D-T pump speed (m3/s)", "(s(4))", s[3], "OP " ) - po.ovarre( + process_output.ovarre( self.outfile, "D-T pump speed provided (m3/s)", "(snet(4))", @@ -640,49 +658,236 @@ def vacuum( ) if nflag == 1: - po.oblnkl(self.outfile) - po.ocmmnt(self.outfile, "Vacuum pumping ducts are space limited.") - po.ocmmnt(self.outfile, f"Maximum duct diameter is only {d1max} m") - po.ocmmnt(self.outfile, "Conductance is inadequate.") - po.oblnkl(self.outfile) + process_output.oblnkl(self.outfile) + process_output.ocmmnt( + self.outfile, "Vacuum pumping ducts are space limited." + ) + process_output.ocmmnt( + self.outfile, f"Maximum duct diameter is only {d1max} m" + ) + process_output.ocmmnt(self.outfile, "Conductance is inadequate.") + process_output.oblnkl(self.outfile) i_fw_blkt_shared_coolant = ( - "cryo " if vacv.i_vacuum_pump_type == 1 else "turbo" + "cryo " if vacuum_variables.i_vacuum_pump_type == 1 else "turbo" ) - po.oblnkl(self.outfile) - po.ocmmnt(self.outfile, "The vacuum pumping system size is governed by the") + process_output.oblnkl(self.outfile) + process_output.ocmmnt( + self.outfile, "The vacuum pumping system size is governed by the" + ) if imax == 1: - po.ocmmnt(self.outfile, "requirements for pumpdown to base pressure.") + process_output.ocmmnt( + self.outfile, "requirements for pumpdown to base pressure." + ) elif imax == 2: - po.ocmmnt(self.outfile, "requirements for pumpdown between burns.") + process_output.ocmmnt( + self.outfile, "requirements for pumpdown between burns." + ) elif imax == 3: - po.ocmmnt(self.outfile, "requirements for helium ash removal.") + process_output.ocmmnt( + self.outfile, "requirements for helium ash removal." + ) else: - po.ocmmnt(self.outfile, "requirements for D-T removal at fuelling rate.") + process_output.ocmmnt( + self.outfile, "requirements for D-T removal at fuelling rate." + ) - po.oblnkl(self.outfile) - po.ovarin(self.outfile, "Number of large pump ducts", "(nduct)", nduct) - po.ovarre( + process_output.oblnkl(self.outfile) + process_output.ovarin( + self.outfile, "Number of large pump ducts", "(nduct)", nduct + ) + process_output.ovarre( self.outfile, "Passage diameter, divertor to ducts (m)", "(d(imax))", d[imax], "OP ", ) - po.ovarre(self.outfile, "Passage length (m)", "(l1)", l1, "OP ") - po.ovarre(self.outfile, "Diameter of ducts (m)", "(dout)", dout, "OP ") + process_output.ovarre(self.outfile, "Passage length (m)", "(l1)", l1, "OP ") + process_output.ovarre( + self.outfile, "Diameter of ducts (m)", "(dout)", dout, "OP " + ) - po.ovarre( + process_output.ovarre( self.outfile, "Duct length, divertor to elbow (m)", "(l2)", l2, "OP " ) - po.ovarre(self.outfile, "Duct length, elbow to pumps (m)", "(l3)", l3) - po.ovarre(self.outfile, "Number of pumps", "(pumpn)", pumpn, "OP ") - po.oblnkl(self.outfile) - po.ocmmnt( + process_output.ovarre( + self.outfile, "Duct length, elbow to pumps (m)", "(l3)", l3 + ) + process_output.ovarre( + self.outfile, "Number of pumps", "(pumpn)", pumpn, "OP " + ) + process_output.oblnkl(self.outfile) + process_output.ocmmnt( self.outfile, f"The vacuum system uses {i_fw_blkt_shared_coolant} pumps.", ) return pumpn, nduct, dlscalc, mvdsh, dimax + + +class VacuumVessel: + """Class containing vacuum vessel routines""" + + def __init__(self) -> None: + pass + + def run(self) -> None: + blanket_library.dz_vv_half = self.calculate_vessel_half_height( + z_tf_inside_half=build_variables.z_tf_inside_half, + dz_shld_vv_gap=build_variables.dz_shld_vv_gap, + dz_vv_lower=build_variables.dz_vv_lower, + n_divertors=divertor_variables.n_divertors, + dz_blkt_upper=build_variables.dz_blkt_upper, + dz_shld_upper=build_variables.dz_shld_upper, + z_plasma_xpoint_upper=build_variables.z_plasma_xpoint_upper, + dr_fw_plasma_gap_inboard=build_variables.dr_fw_plasma_gap_inboard, + dr_fw_plasma_gap_outboard=build_variables.dr_fw_plasma_gap_outboard, + dr_fw_inboard=build_variables.dr_fw_inboard, + dr_fw_outboard=build_variables.dr_fw_outboard, + ) + # D-shaped blanket and shield + if physics_variables.itart == 1 or fwbs_variables.i_fw_blkt_vv_shape == 1: + ( + blanket_library.vol_vv_inboard, + blanket_library.vol_vv_outboard, + fwbs_variables.vol_vv, + ) = self.calculate_dshaped_vessel_volumes( + r_shld_inboard_inner=build_variables.r_shld_inboard_inner, + r_shld_outboard_outer=build_variables.r_shld_outboard_outer, + dz_vv_half=blanket_library.dz_vv_half, + dr_vv_inboard=build_variables.dr_vv_inboard, + dr_vv_outboard=build_variables.dr_vv_outboard, + dz_vv_upper=build_variables.dz_vv_upper, + dz_vv_lower=build_variables.dz_vv_lower, + ) + else: + ( + blanket_library.vol_vv_inboard, + blanket_library.vol_vv_outboard, + fwbs_variables.vol_vv, + ) = self.calculate_elliptical_vessel_volumes( + rmajor=physics_variables.rmajor, + rminor=physics_variables.rminor, + triang=physics_variables.triang, + r_shld_inboard_inner=build_variables.r_shld_inboard_inner, + r_shld_outboard_outer=build_variables.r_shld_outboard_outer, + dz_vv_half=blanket_library.dz_vv_half, + dr_vv_inboard=build_variables.dr_vv_inboard, + dr_vv_outboard=build_variables.dr_vv_outboard, + dz_vv_upper=build_variables.dz_vv_upper, + dz_vv_lower=build_variables.dz_vv_lower, + ) + + # Apply vacuum vessel coverage factor + # moved from dshaped_* and elliptical_* to keep coverage factor + # changes in the same location. + fwbs_variables.vol_vv = fwbs_variables.fvoldw * fwbs_variables.vol_vv + + # Vacuum vessel mass (kg) + fwbs_variables.m_vv = fwbs_variables.vol_vv * fwbs_variables.den_steel + + @staticmethod + def calculate_vessel_half_height( + z_tf_inside_half: float, + dz_shld_vv_gap: float, + dz_vv_lower: float, + n_divertors: int, + dz_blkt_upper: float, + dz_shld_upper: float, + z_plasma_xpoint_upper: float, + dr_fw_plasma_gap_inboard: float, + dr_fw_plasma_gap_outboard: float, + dr_fw_inboard: float, + dr_fw_outboard: float, + ) -> float: + """Calculate vacuum vessel internal half-height (m)""" + + z_bottom = z_tf_inside_half - dz_shld_vv_gap - dz_vv_lower + + # Calculate component internal upper half-height (m) + # If a double null machine then symmetric + if n_divertors == 2: + z_top = z_bottom + else: + z_top = z_plasma_xpoint_upper + 0.5 * ( + dr_fw_plasma_gap_inboard + + dr_fw_plasma_gap_outboard + + dr_fw_inboard + + dr_fw_outboard + ) + + z_top = z_top + dz_blkt_upper + dz_shld_upper + + # Average of top and bottom (m) + return 0.5 * (z_top + z_bottom) + + @staticmethod + def calculate_dshaped_vessel_volumes( + r_shld_inboard_inner: float, + r_shld_outboard_outer: float, + dz_vv_half: float, + dr_vv_inboard: float, + dr_vv_outboard: float, + dz_vv_upper: float, + dz_vv_lower: float, + ) -> tuple[float, float, float]: + """Calculate volumes of D-shaped vacuum vessel segments""" + + r_1 = r_shld_inboard_inner + r_2 = r_shld_outboard_outer - r_1 + + ( + vol_vv_inboard, + vol_vv_outboard, + vol_vv, + ) = dshellvol( + rmajor=r_1, + rminor=r_2, + zminor=dz_vv_half, + drin=dr_vv_inboard, + drout=dr_vv_outboard, + dz=(dz_vv_upper + dz_vv_lower) / 2, + ) + + return vol_vv_inboard, vol_vv_outboard, vol_vv + + @staticmethod + def calculate_elliptical_vessel_volumes( + rmajor: float, + rminor: float, + triang: float, + r_shld_inboard_inner: float, + r_shld_outboard_outer: float, + dz_vv_half: float, + dr_vv_inboard: float, + dr_vv_outboard: float, + dz_vv_upper: float, + dz_vv_lower: float, + ) -> tuple[float, float, float]: + """Calculate volumes of elliptical vacuum vessel segments""" + # Major radius to centre of inboard and outboard ellipses (m) + # (coincident in radius with top of plasma) + r_1 = rmajor - rminor * triang + + # Calculate distance between r1 and outer edge of inboard ... + # ... section (m) + r_2 = r_1 - r_shld_inboard_inner + r_3 = r_shld_outboard_outer - r_1 + + ( + vol_vv_inboard, + vol_vv_outboard, + vol_vv, + ) = eshellvol( + r_1, + r_2, + r_3, + dz_vv_half, + dr_vv_inboard, + dr_vv_outboard, + (dz_vv_upper + dz_vv_lower) / 2, + ) + return vol_vv_inboard, vol_vv_outboard, vol_vv diff --git a/tests/unit/test_blanket_library.py b/tests/unit/test_blanket_library.py index 2ec8f4998..24eb8a252 100644 --- a/tests/unit/test_blanket_library.py +++ b/tests/unit/test_blanket_library.py @@ -537,7 +537,6 @@ class DshapedComponentParam(NamedTuple): dz_blkt_half: Any = None dz_shld_half: Any = None dz_vv_half: Any = None - icomponent: Any = None expected_a_blkt_inboard_surface: Any = None expected_a_blkt_outboard_surface: Any = None expected_a_blkt_total_surface: Any = None @@ -594,7 +593,6 @@ class DshapedComponentParam(NamedTuple): dz_blkt_half=8.25, dz_shld_half=8.75, dz_vv_half=9.4349999999999987, - icomponent=0, expected_a_blkt_inboard_surface=196.97785938008002, expected_a_blkt_outboard_surface=852.24160940262459, expected_a_blkt_total_surface=1049.2194687827046, @@ -611,112 +609,6 @@ class DshapedComponentParam(NamedTuple): expected_vol_vv_outboard=0, expected_icomponent=0, ), - DshapedComponentParam( - r_shld_inboard_inner=1.5, - dr_shld_inboard=0.40000000000000002, - dr_blkt_inboard=0, - dr_fw_inboard=0.018000000000000002, - dr_fw_plasma_gap_inboard=0.10000000000000001, - dr_fw_plasma_gap_outboard=0.10000000000000001, - dr_fw_outboard=0.018000000000000002, - a_blkt_inboard_surface=196.97785938008002, - a_blkt_outboard_surface=852.24160940262459, - a_blkt_total_surface=1049.2194687827046, - dr_blkt_outboard=1, - dz_blkt_upper=0.5, - a_shld_inboard_surface=0, - a_shld_outboard_surface=0, - a_shld_total_surface=0, - dr_shld_outboard=0.30000000000000004, - dz_shld_upper=0.60000000000000009, - r_shld_outboard_outer=8.4000000000000004, - dr_vv_inboard=0.20000000000000001, - dr_vv_outboard=0.30000000000000004, - dz_vv_upper=0.30000000000000004, - dz_vv_lower=0.30000000000000004, - vol_blkt_inboard=0, - vol_blkt_outboard=691.06561956756764, - vol_blkt_total=691.06561956756764, - vol_shld_total=0, - vol_vv=0, - rminor=2.5, - vol_shld_inboard=0, - vol_shld_outboard=0, - vol_vv_inboard=0, - vol_vv_outboard=0, - dz_blkt_half=8.25, - dz_shld_half=8.75, - dz_vv_half=9.4349999999999987, - icomponent=0, - expected_a_blkt_inboard_surface=196.97785938008002, - expected_a_blkt_outboard_surface=852.24160940262459, - expected_a_blkt_total_surface=1049.2194687827046, - expected_a_shld_inboard_surface=208.91591146372122, - expected_a_shld_outboard_surface=1013.8483589087293, - expected_a_shld_total_surface=1222.7642703724505, - expected_vol_blkt_outboard=691.06561956756764, - expected_volblkt=691.06561956756764, - expected_vol_shld_total=450.46122947809488, - expected_vol_vv=0, - expected_vol_shld_inboard=79.896984366095609, - expected_vol_shld_outboard=370.5642451119993, - expected_vol_vv_inboard=0, - expected_vol_vv_outboard=0, - expected_icomponent=1, - ), - DshapedComponentParam( - r_shld_inboard_inner=1.5, - dr_shld_inboard=0.40000000000000002, - dr_blkt_inboard=0, - dr_fw_inboard=0.018000000000000002, - dr_fw_plasma_gap_inboard=0.10000000000000001, - dr_fw_plasma_gap_outboard=0.10000000000000001, - dr_fw_outboard=0.018000000000000002, - a_blkt_inboard_surface=196.97785938008002, - a_blkt_outboard_surface=852.24160940262459, - a_blkt_total_surface=1049.2194687827046, - dr_blkt_outboard=1, - dz_blkt_upper=0.5, - a_shld_inboard_surface=208.91591146372122, - a_shld_outboard_surface=1013.8483589087293, - a_shld_total_surface=1222.7642703724505, - dr_shld_outboard=0.30000000000000004, - dz_shld_upper=0.60000000000000009, - r_shld_outboard_outer=8.4000000000000004, - dr_vv_inboard=0.20000000000000001, - dr_vv_outboard=0.30000000000000004, - dz_vv_upper=0.30000000000000004, - dz_vv_lower=0.30000000000000004, - vol_blkt_inboard=0, - vol_blkt_outboard=691.06561956756764, - vol_blkt_total=691.06561956756764, - vol_shld_total=450.46122947809488, - vol_vv=0, - rminor=2.5, - vol_shld_inboard=79.896984366095609, - vol_shld_outboard=370.5642451119993, - vol_vv_inboard=0, - vol_vv_outboard=0, - dz_blkt_half=8.25, - dz_shld_half=8.75, - dz_vv_half=9.4349999999999987, - icomponent=1, - expected_a_blkt_inboard_surface=196.97785938008002, - expected_a_blkt_outboard_surface=852.24160940262459, - expected_a_blkt_total_surface=1049.2194687827046, - expected_a_shld_inboard_surface=208.91591146372122, - expected_a_shld_outboard_surface=1013.8483589087293, - expected_a_shld_total_surface=1222.7642703724505, - expected_vol_blkt_outboard=691.06561956756764, - expected_volblkt=691.06561956756764, - expected_vol_shld_total=450.46122947809488, - expected_vol_vv=340.45369594344834, - expected_vol_shld_inboard=79.896984366095609, - expected_vol_shld_outboard=370.5642451119993, - expected_vol_vv_inboard=34.253413020620215, - expected_vol_vv_outboard=306.20028292282814, - expected_icomponent=2, - ), ), ) def test_dshaped_component(dshapedcomponentparam, monkeypatch, blanket_library_fixture): @@ -851,7 +743,7 @@ def test_dshaped_component(dshapedcomponentparam, monkeypatch, blanket_library_f ) monkeypatch.setattr(blanket_library, "dz_vv_half", dshapedcomponentparam.dz_vv_half) - blanket_library_fixture.dshaped_component(dshapedcomponentparam.icomponent) + blanket_library_fixture.dshaped_component() assert build_variables.a_blkt_inboard_surface == pytest.approx( dshapedcomponentparam.expected_a_blkt_inboard_surface @@ -978,110 +870,6 @@ class EllipticalComponentParam(NamedTuple): expected_vol_vv_outboard=0, expected_icomponent=0, ), - EllipticalComponentParam( - r_shld_inboard_inner=4.0833333333333339, - dr_shld_inboard=0.30000000000000004, - dr_blkt_inboard=0.70000000000000007, - r_shld_outboard_outer=12.716666666666667, - dr_shld_outboard=0.80000000000000004, - dr_blkt_outboard=1, - a_blkt_inboard_surface=664.9687712975541, - a_blkt_outboard_surface=1101.3666396424403, - a_blkt_total_surface=1766.3354109399943, - dz_blkt_upper=0.85000000000000009, - a_shld_inboard_surface=0, - a_shld_outboard_surface=0, - a_shld_total_surface=0, - dz_shld_upper=0.59999999999999998, - dr_vv_inboard=0.30000000000000004, - dr_vv_outboard=0.30000000000000004, - dz_vv_upper=0.30000000000000004, - dz_vv_lower=0.30000000000000004, - vol_blkt_inboard=315.83946385183026, - vol_blkt_outboard=1020.3677420460117, - vol_blkt_total=1336.207205897842, - vol_shld_total=0, - vol_vv=0, - rmajor=8, - rminor=2.6666666666666665, - triang=0.5, - vol_shld_inboard=0, - vol_shld_outboard=0, - vol_vv_inboard=0, - vol_vv_outboard=0, - dz_blkt_half=5.9532752487304119, - dz_shld_half=6.8032752487304133, - dz_vv_half=7.5032752487304135, - icomponent=1, - expected_a_blkt_inboard_surface=664.9687712975541, - expected_a_blkt_outboard_surface=1101.3666396424403, - expected_a_blkt_total_surface=1766.3354109399943, - expected_a_shld_inboard_surface=700.06731267447844, - expected_a_shld_outboard_surface=1344.1106481995357, - expected_a_shld_total_surface=2044.1779608740142, - expected_vol_blkt_inboard=315.83946385183026, - expected_vol_blkt_outboard=1020.3677420460117, - expected_volblkt=1336.207205897842, - expected_vol_shld_total=1124.4621612595051, - expected_vol_vv=0, - expected_vol_shld_inboard=177.89822933168091, - expected_vol_shld_outboard=946.56393192782434, - expected_vol_vv_inboard=0, - expected_vol_vv_outboard=0, - expected_icomponent=1, - ), - EllipticalComponentParam( - r_shld_inboard_inner=4.0833333333333339, - dr_shld_inboard=0.30000000000000004, - dr_blkt_inboard=0.70000000000000007, - r_shld_outboard_outer=12.716666666666667, - dr_shld_outboard=0.80000000000000004, - dr_blkt_outboard=1, - a_blkt_inboard_surface=664.9687712975541, - a_blkt_outboard_surface=1101.3666396424403, - a_blkt_total_surface=1766.3354109399943, - dz_blkt_upper=0.85000000000000009, - a_shld_inboard_surface=700.06731267447844, - a_shld_outboard_surface=1344.1106481995357, - a_shld_total_surface=2044.1779608740142, - dz_shld_upper=0.59999999999999998, - dr_vv_inboard=0.30000000000000004, - dr_vv_outboard=0.30000000000000004, - dz_vv_upper=0.30000000000000004, - dz_vv_lower=0.30000000000000004, - vol_blkt_inboard=315.83946385183026, - vol_blkt_outboard=1020.3677420460117, - vol_blkt_total=1336.207205897842, - vol_shld_total=1124.4621612595051, - vol_vv=0, - rmajor=8, - rminor=2.6666666666666665, - triang=0.5, - vol_shld_inboard=177.89822933168091, - vol_shld_outboard=946.56393192782434, - vol_vv_inboard=0, - vol_vv_outboard=0, - dz_blkt_half=5.9532752487304119, - dz_shld_half=6.8032752487304133, - dz_vv_half=7.5032752487304135, - icomponent=2, - expected_a_blkt_inboard_surface=664.9687712975541, - expected_a_blkt_outboard_surface=1101.3666396424403, - expected_a_blkt_total_surface=1766.3354109399943, - expected_a_shld_inboard_surface=700.06731267447844, - expected_a_shld_outboard_surface=1344.1106481995357, - expected_a_shld_total_surface=2044.1779608740142, - expected_vol_blkt_inboard=315.83946385183026, - expected_vol_blkt_outboard=1020.3677420460117, - expected_volblkt=1336.207205897842, - expected_vol_shld_total=1124.4621612595051, - expected_vol_vv=584.07334775041659, - expected_vol_shld_inboard=177.89822933168091, - expected_vol_shld_outboard=946.56393192782434, - expected_vol_vv_inboard=143.03162449152501, - expected_vol_vv_outboard=441.04172325889158, - expected_icomponent=2, - ), ), ) def test_elliptical_component( @@ -1156,18 +944,6 @@ def test_elliptical_component( monkeypatch.setattr( build_variables, "dz_shld_upper", ellipticalcomponentparam.dz_shld_upper ) - monkeypatch.setattr( - build_variables, "dr_vv_inboard", ellipticalcomponentparam.dr_vv_inboard - ) - monkeypatch.setattr( - build_variables, "dr_vv_outboard", ellipticalcomponentparam.dr_vv_outboard - ) - monkeypatch.setattr( - build_variables, "dz_vv_upper", ellipticalcomponentparam.dz_vv_upper - ) - monkeypatch.setattr( - build_variables, "dz_vv_lower", ellipticalcomponentparam.dz_vv_lower - ) monkeypatch.setattr( fwbs_variables, "vol_blkt_inboard", ellipticalcomponentparam.vol_blkt_inboard ) @@ -1180,7 +956,6 @@ def test_elliptical_component( monkeypatch.setattr( fwbs_variables, "vol_shld_total", ellipticalcomponentparam.vol_shld_total ) - monkeypatch.setattr(fwbs_variables, "vol_vv", ellipticalcomponentparam.vol_vv) monkeypatch.setattr(physics_variables, "rmajor", ellipticalcomponentparam.rmajor) monkeypatch.setattr(physics_variables, "rminor", ellipticalcomponentparam.rminor) monkeypatch.setattr(physics_variables, "triang", ellipticalcomponentparam.triang) @@ -1190,23 +965,14 @@ def test_elliptical_component( monkeypatch.setattr( blanket_library, "vol_shld_outboard", ellipticalcomponentparam.vol_shld_outboard ) - monkeypatch.setattr( - blanket_library, "vol_vv_inboard", ellipticalcomponentparam.vol_vv_inboard - ) - monkeypatch.setattr( - blanket_library, "vol_vv_outboard", ellipticalcomponentparam.vol_vv_outboard - ) monkeypatch.setattr( blanket_library, "dz_blkt_half", ellipticalcomponentparam.dz_blkt_half ) monkeypatch.setattr( blanket_library, "dz_shld_half", ellipticalcomponentparam.dz_shld_half ) - monkeypatch.setattr( - blanket_library, "dz_vv_half", ellipticalcomponentparam.dz_vv_half - ) - blanket_library_fixture.elliptical_component(ellipticalcomponentparam.icomponent) + blanket_library_fixture.elliptical_component() assert build_variables.a_blkt_inboard_surface == pytest.approx( ellipticalcomponentparam.expected_a_blkt_inboard_surface @@ -1238,30 +1004,18 @@ def test_elliptical_component( assert fwbs_variables.vol_shld_total == pytest.approx( ellipticalcomponentparam.expected_vol_shld_total ) - assert fwbs_variables.vol_vv == pytest.approx( - ellipticalcomponentparam.expected_vol_vv - ) assert blanket_library.vol_shld_inboard == pytest.approx( ellipticalcomponentparam.expected_vol_shld_inboard ) assert blanket_library.vol_shld_outboard == pytest.approx( ellipticalcomponentparam.expected_vol_shld_outboard ) - assert blanket_library.vol_vv_inboard == pytest.approx( - ellipticalcomponentparam.expected_vol_vv_inboard - ) - assert blanket_library.vol_vv_outboard == pytest.approx( - ellipticalcomponentparam.expected_vol_vv_outboard - ) class ApplyCoverageFactorsParam(NamedTuple): a_blkt_outboard_surface: Any = None a_blkt_total_surface: Any = None a_blkt_inboard_surface: Any = None - a_shld_inboard_surface: Any = None - a_shld_outboard_surface: Any = None - a_shld_total_surface: Any = None f_ster_div_single: Any = None f_a_fw_outboard_hcd: Any = None vol_blkt_outboard: Any = None @@ -1270,20 +1024,14 @@ class ApplyCoverageFactorsParam(NamedTuple): fvolsi: Any = None fvolso: Any = None vol_shld_total: Any = None - vol_vv: Any = None - fvoldw: Any = None n_divertors: Any = None vol_shld_inboard: Any = None vol_shld_outboard: Any = None expected_a_blkt_outboard_surface: Any = None expected_a_blkt_total_surface: Any = None - expected_a_shld_outboard_surface: Any = None - expected_a_shld_total_surface: Any = None expected_vol_blkt_outboard: Any = None expected_volblkt: Any = None - expected_vol_shld_total: Any = None expected_vol_vv: Any = None - expected_vol_shld_outboard: Any = None @pytest.mark.parametrize( @@ -1293,9 +1041,6 @@ class ApplyCoverageFactorsParam(NamedTuple): a_blkt_outboard_surface=1101.3666396424403, a_blkt_total_surface=1766.3354109399943, a_blkt_inboard_surface=664.9687712975541, - a_shld_inboard_surface=700.06731267447844, - a_shld_outboard_surface=1344.1106481995357, - a_shld_total_surface=2044.1779608740142, f_ster_div_single=0.115, f_a_fw_outboard_hcd=0, vol_blkt_outboard=1020.3677420460117, @@ -1303,21 +1048,12 @@ class ApplyCoverageFactorsParam(NamedTuple): vol_blkt_total=1336.207205897842, fvolsi=1, fvolso=0.64000000000000001, - vol_shld_total=1124.4621612595051, - vol_vv=584.07334775041659, - fvoldw=1.74, n_divertors=1, - vol_shld_inboard=177.89822933168091, - vol_shld_outboard=946.56393192782434, expected_a_blkt_outboard_surface=898.23806738434075, expected_a_blkt_total_surface=1563.2068386818949, - expected_a_shld_outboard_surface=860.23081484770285, - expected_a_shld_total_surface=1560.2981275221814, expected_vol_blkt_outboard=866.70391336775992, expected_volblkt=1182.5433772195902, - expected_vol_shld_total=783.69914576548854, expected_vol_vv=1016.2876250857248, - expected_vol_shld_outboard=605.80091643380763, ), ), ) @@ -1350,21 +1086,6 @@ def test_apply_coverage_factors( "a_blkt_inboard_surface", applycoveragefactorsparam.a_blkt_inboard_surface, ) - monkeypatch.setattr( - build_variables, - "a_shld_inboard_surface", - applycoveragefactorsparam.a_shld_inboard_surface, - ) - monkeypatch.setattr( - build_variables, - "a_shld_outboard_surface", - applycoveragefactorsparam.a_shld_outboard_surface, - ) - monkeypatch.setattr( - build_variables, - "a_shld_total_surface", - applycoveragefactorsparam.a_shld_total_surface, - ) monkeypatch.setattr( fwbs_variables, "f_ster_div_single", applycoveragefactorsparam.f_ster_div_single ) @@ -1384,22 +1105,9 @@ def test_apply_coverage_factors( ) monkeypatch.setattr(fwbs_variables, "fvolsi", applycoveragefactorsparam.fvolsi) monkeypatch.setattr(fwbs_variables, "fvolso", applycoveragefactorsparam.fvolso) - monkeypatch.setattr( - fwbs_variables, "vol_shld_total", applycoveragefactorsparam.vol_shld_total - ) - monkeypatch.setattr(fwbs_variables, "vol_vv", applycoveragefactorsparam.vol_vv) - monkeypatch.setattr(fwbs_variables, "fvoldw", applycoveragefactorsparam.fvoldw) monkeypatch.setattr( divertor_variables, "n_divertors", applycoveragefactorsparam.n_divertors ) - monkeypatch.setattr( - blanket_library, "vol_shld_inboard", applycoveragefactorsparam.vol_shld_inboard - ) - monkeypatch.setattr( - blanket_library, - "vol_shld_outboard", - applycoveragefactorsparam.vol_shld_outboard, - ) blanket_library_fixture.apply_coverage_factors() @@ -1409,27 +1117,12 @@ def test_apply_coverage_factors( assert build_variables.a_blkt_total_surface == pytest.approx( applycoveragefactorsparam.expected_a_blkt_total_surface ) - assert build_variables.a_shld_outboard_surface == pytest.approx( - applycoveragefactorsparam.expected_a_shld_outboard_surface - ) - assert build_variables.a_shld_total_surface == pytest.approx( - applycoveragefactorsparam.expected_a_shld_total_surface - ) assert fwbs_variables.vol_blkt_outboard == pytest.approx( applycoveragefactorsparam.expected_vol_blkt_outboard ) assert fwbs_variables.vol_blkt_total == pytest.approx( applycoveragefactorsparam.expected_volblkt ) - assert fwbs_variables.vol_shld_total == pytest.approx( - applycoveragefactorsparam.expected_vol_shld_total - ) - assert fwbs_variables.vol_vv == pytest.approx( - applycoveragefactorsparam.expected_vol_vv - ) - assert blanket_library.vol_shld_outboard == pytest.approx( - applycoveragefactorsparam.expected_vol_shld_outboard - ) class BlanketModPolHeightParam(NamedTuple): diff --git a/tests/unit/test_cryostat.py b/tests/unit/test_cryostat.py index 133c07c41..a23cb9c30 100644 --- a/tests/unit/test_cryostat.py +++ b/tests/unit/test_cryostat.py @@ -43,7 +43,6 @@ class ExternalCryoGeometryParam(NamedTuple): expected_r_cryostat_inboard: Any = None expected_z_cryostat_half_inside: Any = None expected_vol_cryostat: Any = None - expected_vvmass: Any = None expected_dewmkg: Any = None expected_dz_tf_cryostat: Any = None expected_dz_pf_cryostat: Any = None @@ -130,7 +129,6 @@ class ExternalCryoGeometryParam(NamedTuple): expected_r_cryostat_inboard=17.805470903073743, expected_z_cryostat_half_inside=15.259637557000296, expected_vol_cryostat=818.1630389343372, - expected_vvmass=7927043.4756686538, expected_dewmkg=14308715.179356484, expected_dz_tf_cryostat=5.514694530398824, expected_dz_pf_cryostat=5.3441455565624985, @@ -207,9 +205,6 @@ def test_external_cryo_geometry( assert fwbs_variables.vol_cryostat == pytest.approx( externalcryogeometryparam.expected_vol_cryostat ) - assert fwbs_variables.m_vv == pytest.approx( - externalcryogeometryparam.expected_vvmass - ) assert fwbs_variables.dewmkg == pytest.approx( externalcryogeometryparam.expected_dewmkg ) diff --git a/tests/unit/test_shield.py b/tests/unit/test_shield.py new file mode 100644 index 000000000..a13cbf8df --- /dev/null +++ b/tests/unit/test_shield.py @@ -0,0 +1,280 @@ +from typing import Any, NamedTuple + +import pytest + +from process.shield import Shield + + +@pytest.fixture +def shield(): + """Provides Shield object for testing. + + :return shield: initialised Shield object + :type shield: process.shield.Shield + """ + return Shield() + + +class EllipticalShieldVolumes(NamedTuple): + rmajor: Any = None + rminor: Any = None + triang: Any = None + r_shld_inboard_inner: Any = None + r_shld_outboard_outer: Any = None + dz_shield_half: Any = None + dr_shield_inboard: Any = None + dr_shield_outboard: Any = None + dz_shield_upper: Any = None + dz_shield_lower: Any = None + + +@pytest.mark.parametrize( + "elliptical_shield_volumes, expected", + [ + ( + EllipticalShieldVolumes( + rmajor=8, + rminor=2.6666666666666665, + triang=0.5, + r_shld_inboard_inner=4.083333333333334, + r_shld_outboard_outer=12.716666666666667, + dz_shield_half=6.8032752487304133, + dr_shield_inboard=0.30000000000000004, + dr_shield_outboard=0.80000000000000004, + dz_shield_upper=0.59999999999999998, + dz_shield_lower=0.59999999999999998, + ), + ( + pytest.approx(177.89822933168091), + pytest.approx(946.56393192782434), + pytest.approx(1124.4621612595051), + ), + ) + ], +) +def test_elliptical_shield_volumes(shield, elliptical_shield_volumes, expected): + """Tests `elliptical_shield_volumes` function. + + :param elliptical_shield_volumes: input parameters for the function + :type elliptical_shield_volumes: EllipticalShieldVolumes + + + """ + + vol_shield_inboard, vol_shield_outboard, vol_shield = ( + shield.calculate_elliptical_shield_volumes( + r_shld_inboard_inner=elliptical_shield_volumes.r_shld_inboard_inner, + r_shld_outboard_outer=elliptical_shield_volumes.r_shld_outboard_outer, + rmajor=elliptical_shield_volumes.rmajor, + triang=elliptical_shield_volumes.triang, + dr_shld_inboard=elliptical_shield_volumes.dr_shield_inboard, + rminor=elliptical_shield_volumes.rminor, + dz_shld_half=elliptical_shield_volumes.dz_shield_half, + dr_shld_outboard=elliptical_shield_volumes.dr_shield_outboard, + dz_shld_upper=elliptical_shield_volumes.dz_shield_upper, + ) + ) + + assert vol_shield_inboard == expected[0] + assert vol_shield_outboard == expected[1] + assert vol_shield == expected[2] + + +class EllipticalShieldAreas(NamedTuple): + rmajor: Any = None + rminor: Any = None + triang: Any = None + r_shld_inboard_inner: Any = None + r_shld_outboard_outer: Any = None + dz_shield_half: Any = None + dr_shield_inboard: Any = None + dr_shield_outboard: Any = None + dz_shield_upper: Any = None + dz_shield_lower: Any = None + + +@pytest.mark.parametrize( + "elliptical_shield_areas, expected", + [ + ( + EllipticalShieldAreas( + rmajor=8, + rminor=2.6666666666666665, + triang=0.5, + r_shld_inboard_inner=4.083333333333334, + r_shld_outboard_outer=12.716666666666667, + dz_shield_half=6.8032752487304133, + dr_shield_inboard=0.30000000000000004, + dr_shield_outboard=0.80000000000000004, + dz_shield_upper=0.59999999999999998, + ), + ( + pytest.approx(700.06731267447844), + pytest.approx(1344.1106481995357), + pytest.approx(2044.1779608740142), + ), + ) + ], +) +def test_elliptical_shield_areas(shield, elliptical_shield_areas, expected): + """Tests `elliptical_shield_areas` function. + :param elliptical_shield_areas: input parameters for the function + :type elliptical_shield_areas: EllipticalShieldAreas + + + """ + + a_shield_inboard, a_shield_outboard, a_shield = ( + shield.calculate_elliptical_shield_areas( + r_shld_inboard_inner=elliptical_shield_areas.r_shld_inboard_inner, + r_shld_outboard_outer=elliptical_shield_areas.r_shld_outboard_outer, + rmajor=elliptical_shield_areas.rmajor, + triang=elliptical_shield_areas.triang, + dr_shld_inboard=elliptical_shield_areas.dr_shield_inboard, + rminor=elliptical_shield_areas.rminor, + dz_shld_half=elliptical_shield_areas.dz_shield_half, + dr_shld_outboard=elliptical_shield_areas.dr_shield_outboard, + ) + ) + + assert a_shield_inboard == expected[0] + assert a_shield_outboard == expected[1] + assert a_shield == expected[2] + + +class DShapedShieldVolumes(NamedTuple): + rminor: Any = None + r_shld_inboard_inner: Any = None + dr_shld_inboard: Any = None + dr_fw_plasma_gap_inboard: Any = None + dr_fw_plasma_gap_outboard: Any = None + dr_fw_inboard: Any = None + dr_fw_outboard: Any = None + dr_blkt_inboard: Any = None + dr_blkt_outboard: Any = None + dz_shld_half: Any = None + dr_shld_outboard: Any = None + dz_shld_upper: Any = None + + +@pytest.mark.parametrize( + "dshaped_shield_volumes, expected", + [ + ( + DShapedShieldVolumes( + rminor=2.5, + dr_shld_inboard=0.40000000000000002, + r_shld_inboard_inner=1.5, + dr_fw_plasma_gap_inboard=0.10000000000000001, + dr_fw_plasma_gap_outboard=0.10000000000000001, + dr_fw_inboard=0.018000000000000002, + dr_fw_outboard=0.018000000000000002, + dr_blkt_inboard=0.0, + dr_blkt_outboard=1.0, + dz_shld_half=8.75, + dr_shld_outboard=0.30000000000000004, + dz_shld_upper=0.6000000000000009, + ), + ( + pytest.approx(79.896984366095609), + pytest.approx(370.5642451119993), + pytest.approx(450.46122947809488), + ), + ) + ], +) +def test_dshaped_shield_volumes(shield, dshaped_shield_volumes, expected): + """Tests `dshaped_shield_volumes` function. + + :param dshaped_shield_volumes: input parameters for the function + :type dshaped_shield_volumes: DShapedShieldVolumes + + + """ + + vol_shield_inboard, vol_shield_outboard, vol_shield = ( + shield.calculate_dshaped_shield_volumes( + r_shld_inboard_inner=dshaped_shield_volumes.r_shld_inboard_inner, + dr_shld_inboard=dshaped_shield_volumes.dr_shld_inboard, + dr_fw_inboard=dshaped_shield_volumes.dr_fw_inboard, + dr_fw_plasma_gap_inboard=dshaped_shield_volumes.dr_fw_plasma_gap_inboard, + rminor=dshaped_shield_volumes.rminor, + dr_fw_plasma_gap_outboard=dshaped_shield_volumes.dr_fw_plasma_gap_outboard, + dr_fw_outboard=dshaped_shield_volumes.dr_fw_outboard, + dr_blkt_inboard=dshaped_shield_volumes.dr_blkt_inboard, + dr_blkt_outboard=dshaped_shield_volumes.dr_blkt_outboard, + dz_shld_half=dshaped_shield_volumes.dz_shld_half, + dr_shld_outboard=dshaped_shield_volumes.dr_shld_outboard, + dz_shld_upper=dshaped_shield_volumes.dz_shld_upper, + ) + ) + + assert vol_shield_inboard == expected[0] + assert vol_shield_outboard == expected[1] + assert vol_shield == expected[2] + + +class DShapedShieldAreas(NamedTuple): + rminor: Any = None + r_shld_inboard_inner: Any = None + dr_shld_inboard: Any = None + dr_fw_plasma_gap_inboard: Any = None + dr_fw_plasma_gap_outboard: Any = None + dr_fw_inboard: Any = None + dr_fw_outboard: Any = None + dr_blkt_inboard: Any = None + dr_blkt_outboard: Any = None + dz_shld_half: Any = None + + +@pytest.mark.parametrize( + "dshaped_shield_areas, expected", + [ + ( + DShapedShieldAreas( + rminor=2.5, + dr_shld_inboard=0.40000000000000002, + r_shld_inboard_inner=1.5, + dr_fw_plasma_gap_inboard=0.10000000000000001, + dr_fw_plasma_gap_outboard=0.10000000000000001, + dr_fw_inboard=0.018000000000000002, + dr_fw_outboard=0.018000000000000002, + dr_blkt_inboard=0.0, + dr_blkt_outboard=1.0, + dz_shld_half=8.75, + ), + ( + pytest.approx(208.91591146372122), + pytest.approx(1013.8483589087293), + pytest.approx(1222.7642703724505), + ), + ) + ], +) +def test_dshaped_shield_areas(shield, dshaped_shield_areas, expected): + """Tests `dshaped_shield_areas` function. + + :param dshaped_shield_areas: input parameters for the function + :type dshaped_shield_areas: DShapedShieldAreas + + + """ + + a_shield_inboard, a_shield_outboard, a_shield = ( + shield.calculate_dshaped_shield_areas( + r_shld_inboard_inner=dshaped_shield_areas.r_shld_inboard_inner, + dr_shld_inboard=dshaped_shield_areas.dr_shld_inboard, + dr_fw_inboard=dshaped_shield_areas.dr_fw_inboard, + dr_fw_plasma_gap_inboard=dshaped_shield_areas.dr_fw_plasma_gap_inboard, + rminor=dshaped_shield_areas.rminor, + dr_fw_plasma_gap_outboard=dshaped_shield_areas.dr_fw_plasma_gap_outboard, + dr_fw_outboard=dshaped_shield_areas.dr_fw_outboard, + dr_blkt_inboard=dshaped_shield_areas.dr_blkt_inboard, + dr_blkt_outboard=dshaped_shield_areas.dr_blkt_outboard, + dz_shld_half=dshaped_shield_areas.dz_shld_half, + ) + ) + + assert a_shield_inboard == expected[0] + assert a_shield_outboard == expected[1] + assert a_shield == expected[2] diff --git a/tests/unit/test_vacuum.py b/tests/unit/test_vacuum.py index 7479f5caf..387f19c7b 100644 --- a/tests/unit/test_vacuum.py +++ b/tests/unit/test_vacuum.py @@ -1,10 +1,12 @@ +from typing import Any, NamedTuple + import pytest from process.data_structure import physics_variables as pv from process.data_structure import tfcoil_variables as tfv from process.data_structure import times_variables as tv from process.data_structure import vacuum_variables as vacv -from process.vacuum import Vacuum +from process.vacuum import Vacuum, VacuumVessel @pytest.fixture @@ -17,6 +19,16 @@ def vacuum(): return Vacuum() +@pytest.fixture +def vacuum_vessel(): + """Provides Vacuum object for testing. + + :return vacuum: initialised Vacuum object + :type vacuum: process.vacuum.Vacuum + """ + return VacuumVessel() + + class TestVacuum: def test_simple_model(self, monkeypatch, vacuum): """Tests `vacuum_simple` subroutine. @@ -109,3 +121,125 @@ def test_old_model(self, monkeypatch, vacuum): assert dlscalc == pytest.approx(2.798765707267961) assert mvdsh == 0.0 assert dimax == pytest.approx(0.42414752916950604) + + +class EllipticalVesselVolumes(NamedTuple): + rmajor: Any = None + rminor: Any = None + triang: Any = None + r_shld_inboard_inner: Any = None + r_shld_outboard_outer: Any = None + dz_vv_half: Any = None + dr_vv_inboard: Any = None + dr_vv_outboard: Any = None + dz_vv_upper: Any = None + dz_vv_lower: Any = None + + +@pytest.mark.parametrize( + "elliptical_vessel_volumes, expected", + [ + ( + EllipticalVesselVolumes( + rmajor=8, + rminor=2.6666666666666665, + triang=0.5, + r_shld_inboard_inner=4.083333333333334, + r_shld_outboard_outer=12.716666666666667, + dz_vv_half=7.5032752487304135, + dr_vv_inboard=0.30000000000000004, + dr_vv_outboard=0.30000000000000004, + dz_vv_upper=0.30000000000000004, + dz_vv_lower=0.30000000000000004, + ), + ( + pytest.approx(143.03162449152501), + pytest.approx(441.04172325889158), + pytest.approx(584.07334775041659), + ), + ) + ], +) +def test_elliptical_vessel_volumes(vacuum_vessel, elliptical_vessel_volumes, expected): + """Tests `elliptical_vessel_volumes` function. + + :param elliptical_vessel_volumes: input parameters for the function + :type elliptical_vessel_volumes: EllipticalVesselVolumes + + + """ + + vol_vv_inboard, vol_vv_outboard, vol_vv = ( + vacuum_vessel.calculate_elliptical_vessel_volumes( + rmajor=elliptical_vessel_volumes.rmajor, + rminor=elliptical_vessel_volumes.rminor, + triang=elliptical_vessel_volumes.triang, + r_shld_inboard_inner=elliptical_vessel_volumes.r_shld_inboard_inner, + r_shld_outboard_outer=elliptical_vessel_volumes.r_shld_outboard_outer, + dz_vv_half=elliptical_vessel_volumes.dz_vv_half, + dr_vv_inboard=elliptical_vessel_volumes.dr_vv_inboard, + dr_vv_outboard=elliptical_vessel_volumes.dr_vv_outboard, + dz_vv_upper=elliptical_vessel_volumes.dz_vv_upper, + dz_vv_lower=elliptical_vessel_volumes.dz_vv_lower, + ) + ) + + assert vol_vv_inboard == expected[0] + assert vol_vv_outboard == expected[1] + assert vol_vv == expected[2] + + +class DShapedVesselVolumes(NamedTuple): + r_shld_inboard_inner: Any = None + r_shld_outboard_outer: Any = None + dz_vv_half: Any = None + dr_vv_inboard: Any = None + dr_vv_outboard: Any = None + dz_vv_upper: Any = None + dz_vv_lower: Any = None + + +@pytest.mark.parametrize( + "dshaped_vessel_volumes, expected", + [ + ( + DShapedVesselVolumes( + r_shld_inboard_inner=1.5, + r_shld_outboard_outer=8.4000000000000004, + dz_vv_half=9.4349999999999987, + dr_vv_inboard=0.20000000000000001, + dr_vv_outboard=0.30000000000000004, + dz_vv_upper=0.30000000000000004, + dz_vv_lower=0.30000000000000004, + ), + ( + pytest.approx(34.253413020620215), + pytest.approx(306.20028292282814), + pytest.approx(340.45369594344834), + ), + ) + ], +) +def test_dshaped_vessel_volumes(vacuum_vessel, dshaped_vessel_volumes, expected): + """Tests `dshaped_vessel_volumes` function. + + :param dshaped_vessel_volumes: input parameters for the function + :type dshaped_vessel_volumes: DShapedVesselVolumes + + """ + + vol_vv_inboard, vol_vv_outboard, vol_vv = ( + vacuum_vessel.calculate_dshaped_vessel_volumes( + r_shld_inboard_inner=dshaped_vessel_volumes.r_shld_inboard_inner, + r_shld_outboard_outer=dshaped_vessel_volumes.r_shld_outboard_outer, + dz_vv_half=dshaped_vessel_volumes.dz_vv_half, + dr_vv_inboard=dshaped_vessel_volumes.dr_vv_inboard, + dr_vv_outboard=dshaped_vessel_volumes.dr_vv_outboard, + dz_vv_upper=dshaped_vessel_volumes.dz_vv_upper, + dz_vv_lower=dshaped_vessel_volumes.dz_vv_lower, + ) + ) + + assert vol_vv_inboard == expected[0] + assert vol_vv_outboard == expected[1] + assert vol_vv == expected[2]