From 1f97c2b51bd39ab82e57d53ff04d5b2a284f1ea3 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 19 Mar 2025 11:52:50 +0000 Subject: [PATCH 1/3] Refactor cryostat geometry calculations into a new Cryostat class and update related modules --- process/blanket_library.py | 68 ------------------ process/build.py | 59 ---------------- process/caller.py | 2 + process/cryostat.py | 141 +++++++++++++++++++++++++++++++++++++ process/main.py | 2 + process/output.py | 3 + 6 files changed, 148 insertions(+), 127 deletions(-) create mode 100644 process/cryostat.py diff --git a/process/blanket_library.py b/process/blanket_library.py index 1cbf3c42d6..c70d423a72 100644 --- a/process/blanket_library.py +++ b/process/blanket_library.py @@ -12,13 +12,11 @@ from process.fortran import ( blanket_library, build_variables, - buildings_variables, constants, divertor_variables, error_handling, fwbs_variables, heat_transport_variables, - pfcoil_variables, physics_variables, primary_pumping_variables, ) @@ -83,9 +81,6 @@ def component_volumes(self): # Apply coverage factors to volumes and surface areas self.apply_coverage_factors() - # Calculate cryostat geometry - self.external_cryo_geometry() - def component_half_height(self, icomponent: int): """Calculate the blanket, shield or vacuum vessel half-height Based on blanket_half_height, shield_half_height, vv_half_height @@ -373,69 +368,6 @@ def apply_coverage_factors(self): # changes in the same location. fwbs_variables.vol_vv = fwbs_variables.fvoldw * fwbs_variables.vol_vv - @staticmethod - def external_cryo_geometry() -> None: - """Calculate cryostat geometry. - - This method calculates the geometry of the cryostat, including the inboard radius, - the vertical clearance between the uppermost PF coil and the cryostat lid, the half-height - of the cryostat, the vertical clearance between the TF coil and the cryostat, the cryostat volume, - the vacuum vessel mass, and the sum of internal vacuum vessel and cryostat masses. - - """ - - # Cryostat radius [m] - # Take radius of furthest PF coil and add clearance - fwbs_variables.r_cryostat_inboard = ( - np.max(pfcoil_variables.r_pf_coil_outer) + fwbs_variables.dr_pf_cryostat - ) - - # Clearance between uppermost PF coil and cryostat lid [m]. - # Scaling from ITER by M. Kovari - blanket_library.dz_pf_cryostat = ( - build_variables.f_z_cryostat - * (2.0 * fwbs_variables.r_cryostat_inboard) - / 28.440 - ) - - # Half-height of cryostat [m] - # Take height of furthest PF coil and add clearance - fwbs_variables.z_cryostat_half_inside = ( - np.max(pfcoil_variables.z_pf_coil_upper) + blanket_library.dz_pf_cryostat - ) - - # Vertical clearance between TF coil and cryostat (m) - buildings_variables.dz_tf_cryostat = fwbs_variables.z_cryostat_half_inside - ( - build_variables.hmax + build_variables.dr_tf_inboard - ) - - # Internal cryostat space volume [m^3] - fwbs_variables.vol_cryostat_internal = ( - np.pi - * (fwbs_variables.r_cryostat_inboard) ** 2 - * 2 - * fwbs_variables.z_cryostat_half_inside - ) - - # Cryostat structure volume [m^3] - # Calculate by taking the volume of the outer cryostat and subtracting the volume of the inner cryostat - fwbs_variables.vol_cryostat = ( - ( - np.pi - * (fwbs_variables.r_cryostat_inboard + build_variables.dr_cryostat) ** 2 - ) - * 2 - * (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.denstl - - # Sum of internal vacuum vessel and cryostat masses (kg) - fwbs_variables.dewmkg = ( - fwbs_variables.vol_vv + fwbs_variables.vol_cryostat - ) * fwbs_variables.denstl - 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/build.py b/process/build.py index 30b1e7e5e5..75336c4938 100644 --- a/process/build.py +++ b/process/build.py @@ -5,7 +5,6 @@ from process import process_output as po from process.blanket_library import dshellarea, eshellarea from process.fortran import ( - blanket_library, build_variables, buildings_variables, constants, @@ -723,11 +722,6 @@ def calculate_vertical_build(self, output: bool) -> None: "\n*Cryostat roof allowance includes uppermost PF coil and outer thermal shield.\n*Cryostat floor allowance includes lowermost PF coil, outer thermal shield and gravity support.", ) - # Other build quantities - - # Output the cryostat geometry - _ = self.cryostat_output(output) - # Output the cdivertor geometry divht = self.divgeom(output) # Issue #481 Remove build_variables.vgaptf @@ -773,59 +767,6 @@ def calculate_vertical_build(self, output: bool) -> None: - (build_variables.hmax + build_variables.dr_tf_inboard) ) / 2.0e0 - def cryostat_output(self, output: bool) -> None: - """ - Outputs the cryostat geometry details to the output file. - - Returns: - None - """ - if output: - po.oheadr(self.outfile, "Cryostat build") - - po.ovarrf( - self.outfile, - "Cryostat thickness (m)", - "(dr_cryostat)", - build_variables.dr_cryostat, - "OP ", - ) - po.ovarrf( - self.outfile, - "Cryostat internal radius (m)", - "(r_cryostat_inboard)", - fwbs_variables.r_cryostat_inboard, - "OP ", - ) - po.ovarrf( - self.outfile, - "Cryostat intenral half height (m)", - "(z_cryostat_half_inside)", - fwbs_variables.z_cryostat_half_inside, - "OP ", - ) - po.ovarrf( - self.outfile, - "Vertical clearance from highest PF coil to cryostat (m)", - "(dz_pf_cryostat)", - blanket_library.dz_pf_cryostat, - "OP ", - ) - po.ovarrf( - self.outfile, - "Cryostat structure volume (m^3)", - "(vol_cryostat)", - fwbs_variables.vol_cryostat, - "OP ", - ) - po.ovarrf( - self.outfile, - "Cryostat internal volume (m^3)", - "(vol_cryostat_internal)", - fwbs_variables.vol_cryostat_internal, - "OP ", - ) - def divgeom(self, output: bool): """ Divertor geometry calculation diff --git a/process/caller.py b/process/caller.py index be6f9b2362..041a6279a4 100644 --- a/process/caller.py +++ b/process/caller.py @@ -302,6 +302,8 @@ def _call_models_once(self, xc: np.ndarray) -> None: self.models.divertor.run(output=False) + self.models.cryostat.run() + # Structure Model self.models.structure.run(output=False) diff --git a/process/cryostat.py b/process/cryostat.py new file mode 100644 index 0000000000..282f94e9de --- /dev/null +++ b/process/cryostat.py @@ -0,0 +1,141 @@ +import numpy as np + +from process import process_output as po +from process.fortran import ( + blanket_library, + build_variables, + buildings_variables, + constants, + fwbs_variables, + pfcoil_variables, +) + + +class Cryostat: + def __init__(self) -> None: + self.outfile = constants.nout + + def run(self) -> None: + """Run the cryostat calculations. + + This method runs the cryostat calculations, including the calculation of the cryostat geometry. + + """ + + # Calculate cryostat geometry + self.external_cryo_geometry() + + @staticmethod + def external_cryo_geometry() -> None: + """Calculate cryostat geometry. + + This method calculates the geometry of the cryostat, including the inboard radius, + the vertical clearance between the uppermost PF coil and the cryostat lid, the half-height + of the cryostat, the vertical clearance between the TF coil and the cryostat, the cryostat volume, + the vacuum vessel mass, and the sum of internal vacuum vessel and cryostat masses. + + """ + + # Cryostat radius [m] + # Take radius of furthest PF coil and add clearance + fwbs_variables.r_cryostat_inboard = ( + np.max(pfcoil_variables.r_pf_coil_outer) + fwbs_variables.dr_pf_cryostat + ) + + # Clearance between uppermost PF coil and cryostat lid [m]. + # Scaling from ITER by M. Kovari + blanket_library.dz_pf_cryostat = ( + build_variables.f_z_cryostat + * (2.0 * fwbs_variables.r_cryostat_inboard) + / 28.440 + ) + + # Half-height of cryostat [m] + # Take height of furthest PF coil and add clearance + fwbs_variables.z_cryostat_half_inside = ( + np.max(pfcoil_variables.z_pf_coil_upper) + blanket_library.dz_pf_cryostat + ) + + # Vertical clearance between TF coil and cryostat (m) + buildings_variables.dz_tf_cryostat = fwbs_variables.z_cryostat_half_inside - ( + build_variables.hmax + build_variables.dr_tf_inboard + ) + + # Internal cryostat space volume [m^3] + fwbs_variables.vol_cryostat_internal = ( + np.pi + * (fwbs_variables.r_cryostat_inboard) ** 2 + * 2 + * fwbs_variables.z_cryostat_half_inside + ) + + # Cryostat structure volume [m^3] + # Calculate by taking the volume of the outer cryostat and subtracting the volume of the inner cryostat + fwbs_variables.vol_cryostat = ( + ( + np.pi + * (fwbs_variables.r_cryostat_inboard + build_variables.dr_cryostat) ** 2 + ) + * 2 + * (build_variables.dr_cryostat + fwbs_variables.z_cryostat_half_inside) + ) - (fwbs_variables.vol_cryostat_internal) + + # Vacuum vessel mass (kg) + fwbs_variables.vvmass = fwbs_variables.vdewin * fwbs_variables.denstl + + # Sum of internal vacuum vessel and cryostat masses (kg) + fwbs_variables.dewmkg = ( + fwbs_variables.vdewin + fwbs_variables.vol_cryostat + ) * fwbs_variables.denstl + + def cryostat_output(self) -> None: + """ + Outputs the cryostat geometry details to the output file. + + Returns: + None + """ + po.oheadr(self.outfile, "Cryostat build") + + po.ovarrf( + self.outfile, + "Cryostat thickness (m)", + "(dr_cryostat)", + build_variables.dr_cryostat, + "OP ", + ) + po.ovarrf( + self.outfile, + "Cryostat internal radius (m)", + "(r_cryostat_inboard)", + fwbs_variables.r_cryostat_inboard, + "OP ", + ) + po.ovarrf( + self.outfile, + "Cryostat intenral half height (m)", + "(z_cryostat_half_inside)", + fwbs_variables.z_cryostat_half_inside, + "OP ", + ) + po.ovarrf( + self.outfile, + "Vertical clearance from highest PF coil to cryostat (m)", + "(dz_pf_cryostat)", + blanket_library.dz_pf_cryostat, + "OP ", + ) + po.ovarrf( + self.outfile, + "Cryostat structure volume (m^3)", + "(vol_cryostat)", + fwbs_variables.vol_cryostat, + "OP ", + ) + po.ovarrf( + self.outfile, + "Cryostat internal volume (m^3)", + "(vol_cryostat_internal)", + fwbs_variables.vol_cryostat_internal, + "OP ", + ) diff --git a/process/main.py b/process/main.py index eb2a3f5bbc..db5c7e3a6f 100644 --- a/process/main.py +++ b/process/main.py @@ -57,6 +57,7 @@ from process.caller import write_output_files from process.costs import Costs from process.costs_2015 import Costs2015 +from process.cryostat import Cryostat from process.cs_fatigue import CsFatigue from process.current_drive import CurrentDrive from process.dcll import DCLL @@ -654,6 +655,7 @@ def __init__(self): self.cs_fatigue = CsFatigue() self.pfcoil = PFCoil(cs_fatigue=self.cs_fatigue) self.power = Power() + self.cryostat = Cryostat() self.build = Build() self.sctfcoil = Sctfcoil() self.tfcoil = TFcoil(build=self.build, sctfcoil=self.sctfcoil) diff --git a/process/output.py b/process/output.py index cb0e3bcd48..6dabdbf423 100644 --- a/process/output.py +++ b/process/output.py @@ -58,6 +58,9 @@ def write(models, _outfile): # Vertical build models.build.calculate_vertical_build(output=True) + # Cryostat build + models.cryostat.cryostat_output() + # Toroidal field coil model models.tfcoil.output() From 95dd65faf0d41737aa5c145b6ada3a90ce66e113 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 19 Mar 2025 13:25:12 +0000 Subject: [PATCH 2/3] Add unit tests for Cryostat external cryo geometry calculations --- tests/unit/test_blanket_library.py | 196 -------------------------- tests/unit/test_cryostat.py | 219 +++++++++++++++++++++++++++++ 2 files changed, 219 insertions(+), 196 deletions(-) create mode 100644 tests/unit/test_cryostat.py diff --git a/tests/unit/test_blanket_library.py b/tests/unit/test_blanket_library.py index cc43e77c92..cfdc4c1ad1 100644 --- a/tests/unit/test_blanket_library.py +++ b/tests/unit/test_blanket_library.py @@ -7,10 +7,8 @@ from process.fortran import ( blanket_library, build_variables, - buildings_variables, divertor_variables, fwbs_variables, - pfcoil_variables, physics_variables, ) from process.fw import Fw @@ -1306,200 +1304,6 @@ def test_apply_coverage_factors( ) -class ExternalCryoGeometryParam(NamedTuple): - f_z_cryostat: Any = None - hmax: Any = None - dr_tf_inboard: Any = None - dr_cryostat: Any = None - r_cryostat_inboard: Any = None - dr_pf_cryostat: Any = None - z_cryostat_half_inside: Any = None - vol_cryostat: Any = None - m_vv: Any = None - vol_vv: Any = None - denstl: Any = None - dewmkg: Any = None - r_pf_coil_outer: Any = None - z_pf_coil_upper: Any = None - dz_tf_cryostat: Any = None - dz_pf_cryostat: Any = None - expected_r_cryostat_inboard: Any = None - expected_z_cryostat_half_inside: Any = None - expected_vol_cryostat: Any = None - expected_m_vv: Any = None - expected_dewmkg: Any = None - expected_dz_tf_cryostat: Any = None - expected_dz_pf_cryostat: Any = None - - -@pytest.mark.parametrize( - "externalcryogeometryparam", - ( - ExternalCryoGeometryParam( - f_z_cryostat=4.2679999999999998, - hmax=8.8182171641274945, - dr_tf_inboard=0.92672586247397692, - dr_cryostat=0.15000000000000002, - r_cryostat_inboard=0, - dr_pf_cryostat=0.5, - z_cryostat_half_inside=0, - vol_cryostat=0, - m_vv=0, - vol_vv=1016.2876250857248, - denstl=7800, - dewmkg=0, - r_pf_coil_outer=np.array( - np.array( - ( - 6.1290994712971543, - 6.2110624909068086, - 17.305470903073743, - 17.305470903073743, - 15.620546715016166, - 15.620546715016166, - 2.5506597842255361, - 10.666666666666666, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ), - order="F", - ), - order="F", - ).transpose(), - z_pf_coil_upper=np.array( - np.array( - ( - 9.9154920004377978, - -11.249338850841614, - 3.2350365669570316, - -3.2350365669570316, - 7.8723998771612473, - -7.8723998771612473, - 7.9363954477147454, - 4.9333333333333336, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ), - order="F", - ), - order="F", - ).transpose(), - dz_tf_cryostat=2.5, - dz_pf_cryostat=0, - expected_r_cryostat_inboard=17.805470903073743, - expected_z_cryostat_half_inside=15.259637557000296, - expected_vol_cryostat=818.1630389343372, - expected_m_vv=7927043.4756686538, - expected_dewmkg=14308715.179356484, - expected_dz_tf_cryostat=5.514694530398824, - expected_dz_pf_cryostat=5.3441455565624985, - ), - ), -) -def test_external_cryo_geometry( - externalcryogeometryparam, monkeypatch, blanket_library_fixture -): - """ - Automatically generated Regression Unit Test for external_cryo_geometry. - - This test was generated using data from tests/regression/input_files/large_tokamak_once_through.IN.DAT. - - :param externalcryogeometryparam: the data used to mock and assert in this test. - :type externalcryogeometryparam: externalcryogeometryparam - - :param monkeypatch: pytest fixture used to mock module/class variables - :type monkeypatch: _pytest.monkeypatch.monkeypatch - """ - monkeypatch.setattr( - build_variables, "f_z_cryostat", externalcryogeometryparam.f_z_cryostat - ) - monkeypatch.setattr(build_variables, "hmax", externalcryogeometryparam.hmax) - monkeypatch.setattr( - build_variables, "dr_tf_inboard", externalcryogeometryparam.dr_tf_inboard - ) - monkeypatch.setattr( - build_variables, "dr_cryostat", externalcryogeometryparam.dr_cryostat - ) - monkeypatch.setattr( - fwbs_variables, - "r_cryostat_inboard", - externalcryogeometryparam.r_cryostat_inboard, - ) - monkeypatch.setattr( - fwbs_variables, "dr_pf_cryostat", externalcryogeometryparam.dr_pf_cryostat - ) - monkeypatch.setattr( - fwbs_variables, - "z_cryostat_half_inside", - externalcryogeometryparam.z_cryostat_half_inside, - ) - monkeypatch.setattr( - fwbs_variables, "vol_cryostat", externalcryogeometryparam.vol_cryostat - ) - monkeypatch.setattr(fwbs_variables, "m_vv", externalcryogeometryparam.m_vv) - monkeypatch.setattr(fwbs_variables, "vol_vv", externalcryogeometryparam.vol_vv) - monkeypatch.setattr(fwbs_variables, "denstl", externalcryogeometryparam.denstl) - monkeypatch.setattr(fwbs_variables, "dewmkg", externalcryogeometryparam.dewmkg) - monkeypatch.setattr( - pfcoil_variables, "r_pf_coil_outer", externalcryogeometryparam.r_pf_coil_outer - ) - monkeypatch.setattr( - pfcoil_variables, "z_pf_coil_upper", externalcryogeometryparam.z_pf_coil_upper - ) - monkeypatch.setattr( - buildings_variables, "dz_tf_cryostat", externalcryogeometryparam.dz_tf_cryostat - ) - monkeypatch.setattr( - blanket_library, "dz_pf_cryostat", externalcryogeometryparam.dz_pf_cryostat - ) - - blanket_library_fixture.external_cryo_geometry() - - assert fwbs_variables.r_cryostat_inboard == pytest.approx( - externalcryogeometryparam.expected_r_cryostat_inboard - ) - assert fwbs_variables.z_cryostat_half_inside == pytest.approx( - externalcryogeometryparam.expected_z_cryostat_half_inside - ) - assert fwbs_variables.vol_cryostat == pytest.approx( - externalcryogeometryparam.expected_vol_cryostat - ) - assert fwbs_variables.m_vv == pytest.approx(externalcryogeometryparam.expected_m_vv) - assert fwbs_variables.dewmkg == pytest.approx( - externalcryogeometryparam.expected_dewmkg - ) - assert buildings_variables.dz_tf_cryostat == pytest.approx( - externalcryogeometryparam.expected_dz_tf_cryostat - ) - assert blanket_library.dz_pf_cryostat == pytest.approx( - externalcryogeometryparam.expected_dz_pf_cryostat - ) - - class BlanketModPolHeightParam(NamedTuple): dr_fw_plasma_gap_inboard: Any = None dr_fw_plasma_gap_outboard: Any = None diff --git a/tests/unit/test_cryostat.py b/tests/unit/test_cryostat.py new file mode 100644 index 0000000000..8f8bccf0c4 --- /dev/null +++ b/tests/unit/test_cryostat.py @@ -0,0 +1,219 @@ +from typing import Any, NamedTuple + +import numpy as np +import pytest + +from process.cryostat import Cryostat +from process.fortran import ( + blanket_library, + build_variables, + buildings_variables, + fwbs_variables, + pfcoil_variables, +) + + +@pytest.fixture +def cryostat_fixture(): + """Provides BlanketLibrary object for testing. + + :returns: initialised BlanketLibrary object + :rtype: process.blanket_library.BlanketLibrary + """ + return Cryostat() + + +class ExternalCryoGeometryParam(NamedTuple): + f_z_cryostat: Any = None + hmax: Any = None + dr_tf_inboard: Any = None + dr_cryostat: Any = None + r_cryostat_inboard: Any = None + dr_pf_cryostat: Any = None + z_cryostat_half_inside: Any = None + vol_cryostat: Any = None + vvmass: Any = None + vdewin: Any = None + denstl: Any = None + dewmkg: Any = None + r_pf_coil_outer: Any = None + z_pf_coil_upper: Any = None + dz_tf_cryostat: Any = None + dz_pf_cryostat: Any = None + 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 + + +@pytest.mark.parametrize( + "externalcryogeometryparam", + ( + ExternalCryoGeometryParam( + f_z_cryostat=4.2679999999999998, + hmax=8.8182171641274945, + dr_tf_inboard=0.92672586247397692, + dr_cryostat=0.15000000000000002, + r_cryostat_inboard=0, + dr_pf_cryostat=0.5, + z_cryostat_half_inside=0, + vol_cryostat=0, + vvmass=0, + vdewin=1016.2876250857248, + denstl=7800, + dewmkg=0, + r_pf_coil_outer=np.array( + np.array( + ( + 6.1290994712971543, + 6.2110624909068086, + 17.305470903073743, + 17.305470903073743, + 15.620546715016166, + 15.620546715016166, + 2.5506597842255361, + 10.666666666666666, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ), + order="F", + ), + order="F", + ).transpose(), + z_pf_coil_upper=np.array( + np.array( + ( + 9.9154920004377978, + -11.249338850841614, + 3.2350365669570316, + -3.2350365669570316, + 7.8723998771612473, + -7.8723998771612473, + 7.9363954477147454, + 4.9333333333333336, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ), + order="F", + ), + order="F", + ).transpose(), + dz_tf_cryostat=2.5, + dz_pf_cryostat=0, + 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, + ), + ), +) +def test_external_cryo_geometry( + externalcryogeometryparam, monkeypatch, cryostat_fixture +): + """ + Automatically generated Regression Unit Test for external_cryo_geometry. + + This test was generated using data from tests/regression/input_files/large_tokamak_once_through.IN.DAT. + + :param externalcryogeometryparam: the data used to mock and assert in this test. + :type externalcryogeometryparam: externalcryogeometryparam + + :param monkeypatch: pytest fixture used to mock module/class variables + :type monkeypatch: _pytest.monkeypatch.monkeypatch + """ + monkeypatch.setattr( + build_variables, "f_z_cryostat", externalcryogeometryparam.f_z_cryostat + ) + monkeypatch.setattr(build_variables, "hmax", externalcryogeometryparam.hmax) + monkeypatch.setattr( + build_variables, "dr_tf_inboard", externalcryogeometryparam.dr_tf_inboard + ) + monkeypatch.setattr( + build_variables, "dr_cryostat", externalcryogeometryparam.dr_cryostat + ) + monkeypatch.setattr( + fwbs_variables, + "r_cryostat_inboard", + externalcryogeometryparam.r_cryostat_inboard, + ) + monkeypatch.setattr( + fwbs_variables, "dr_pf_cryostat", externalcryogeometryparam.dr_pf_cryostat + ) + monkeypatch.setattr( + fwbs_variables, + "z_cryostat_half_inside", + externalcryogeometryparam.z_cryostat_half_inside, + ) + monkeypatch.setattr( + fwbs_variables, "vol_cryostat", externalcryogeometryparam.vol_cryostat + ) + monkeypatch.setattr(fwbs_variables, "vvmass", externalcryogeometryparam.vvmass) + monkeypatch.setattr(fwbs_variables, "vdewin", externalcryogeometryparam.vdewin) + monkeypatch.setattr(fwbs_variables, "denstl", externalcryogeometryparam.denstl) + monkeypatch.setattr(fwbs_variables, "dewmkg", externalcryogeometryparam.dewmkg) + monkeypatch.setattr( + pfcoil_variables, "r_pf_coil_outer", externalcryogeometryparam.r_pf_coil_outer + ) + monkeypatch.setattr( + pfcoil_variables, "z_pf_coil_upper", externalcryogeometryparam.z_pf_coil_upper + ) + monkeypatch.setattr( + buildings_variables, "dz_tf_cryostat", externalcryogeometryparam.dz_tf_cryostat + ) + monkeypatch.setattr( + blanket_library, "dz_pf_cryostat", externalcryogeometryparam.dz_pf_cryostat + ) + + cryostat_fixture.external_cryo_geometry() + + assert fwbs_variables.r_cryostat_inboard == pytest.approx( + externalcryogeometryparam.expected_r_cryostat_inboard + ) + assert fwbs_variables.z_cryostat_half_inside == pytest.approx( + externalcryogeometryparam.expected_z_cryostat_half_inside + ) + assert fwbs_variables.vol_cryostat == pytest.approx( + externalcryogeometryparam.expected_vol_cryostat + ) + assert fwbs_variables.vvmass == pytest.approx( + externalcryogeometryparam.expected_vvmass + ) + assert fwbs_variables.dewmkg == pytest.approx( + externalcryogeometryparam.expected_dewmkg + ) + assert buildings_variables.dz_tf_cryostat == pytest.approx( + externalcryogeometryparam.expected_dz_tf_cryostat + ) + assert blanket_library.dz_pf_cryostat == pytest.approx( + externalcryogeometryparam.expected_dz_pf_cryostat + ) From b78bf24f15b90983ebcc167b1d55b863d0b72c1a Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 21 Mar 2025 09:10:04 +0000 Subject: [PATCH 3/3] Rename vacuum vessel mass variable and update related tests --- process/cryostat.py | 4 ++-- tests/unit/test_cryostat.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/process/cryostat.py b/process/cryostat.py index 282f94e9de..4e64d346df 100644 --- a/process/cryostat.py +++ b/process/cryostat.py @@ -81,11 +81,11 @@ def external_cryo_geometry() -> None: ) - (fwbs_variables.vol_cryostat_internal) # Vacuum vessel mass (kg) - fwbs_variables.vvmass = fwbs_variables.vdewin * fwbs_variables.denstl + fwbs_variables.m_vv = fwbs_variables.vol_vv * fwbs_variables.denstl # Sum of internal vacuum vessel and cryostat masses (kg) fwbs_variables.dewmkg = ( - fwbs_variables.vdewin + fwbs_variables.vol_cryostat + fwbs_variables.vol_vv + fwbs_variables.vol_cryostat ) * fwbs_variables.denstl def cryostat_output(self) -> None: diff --git a/tests/unit/test_cryostat.py b/tests/unit/test_cryostat.py index 8f8bccf0c4..236668093f 100644 --- a/tests/unit/test_cryostat.py +++ b/tests/unit/test_cryostat.py @@ -32,8 +32,8 @@ class ExternalCryoGeometryParam(NamedTuple): dr_pf_cryostat: Any = None z_cryostat_half_inside: Any = None vol_cryostat: Any = None - vvmass: Any = None - vdewin: Any = None + m_vv: Any = None + vol_vv: Any = None denstl: Any = None dewmkg: Any = None r_pf_coil_outer: Any = None @@ -61,8 +61,8 @@ class ExternalCryoGeometryParam(NamedTuple): dr_pf_cryostat=0.5, z_cryostat_half_inside=0, vol_cryostat=0, - vvmass=0, - vdewin=1016.2876250857248, + m_vv=0, + vol_vv=1016.2876250857248, denstl=7800, dewmkg=0, r_pf_coil_outer=np.array( @@ -177,8 +177,8 @@ def test_external_cryo_geometry( monkeypatch.setattr( fwbs_variables, "vol_cryostat", externalcryogeometryparam.vol_cryostat ) - monkeypatch.setattr(fwbs_variables, "vvmass", externalcryogeometryparam.vvmass) - monkeypatch.setattr(fwbs_variables, "vdewin", externalcryogeometryparam.vdewin) + monkeypatch.setattr(fwbs_variables, "m_vv", externalcryogeometryparam.m_vv) + monkeypatch.setattr(fwbs_variables, "vol_vv", externalcryogeometryparam.vol_vv) monkeypatch.setattr(fwbs_variables, "denstl", externalcryogeometryparam.denstl) monkeypatch.setattr(fwbs_variables, "dewmkg", externalcryogeometryparam.dewmkg) monkeypatch.setattr( @@ -205,7 +205,7 @@ def test_external_cryo_geometry( assert fwbs_variables.vol_cryostat == pytest.approx( externalcryogeometryparam.expected_vol_cryostat ) - assert fwbs_variables.vvmass == pytest.approx( + assert fwbs_variables.m_vv == pytest.approx( externalcryogeometryparam.expected_vvmass ) assert fwbs_variables.dewmkg == pytest.approx(