diff --git a/tests/phases/design/test_electrical_design.py b/tests/phases/design/test_electrical_design.py index b248d28f..45e03155 100644 --- a/tests/phases/design/test_electrical_design.py +++ b/tests/phases/design/test_electrical_design.py @@ -43,63 +43,69 @@ def test_parameter_sweep(distance_to_landfall, depth, plant_cap, cable): "substation_design": {}, } - o = ElectricalDesign(config) - o.run() + elect = ElectricalDesign(config) + elect.run() # Check valid substructure length - assert 10 <= o._outputs["offshore_substation_substructure"]["length"] <= 80 + assert ( + 10 + <= elect._outputs["offshore_substation_substructure"]["length"] + <= 80 + ) # Check valid substructure mass assert ( - 200 <= o._outputs["offshore_substation_substructure"]["mass"] <= 2700 + 200 + <= elect._outputs["offshore_substation_substructure"]["mass"] + <= 2700 ) # Check valid topside mass - assert 200 <= o._outputs["offshore_substation_topside"]["mass"] <= 5500 + assert 200 <= elect._outputs["offshore_substation_topside"]["mass"] <= 5500 # Check valid substation cost - assert 1e6 <= o.total_substation_cost <= 1e9 + assert 1e6 <= elect.total_substation_cost <= 1e9 def test_detailed_design_length(): """Ensure that the same # of output variables are used for a floating and fixed offshore substation.""" - o = ElectricalDesign(base) - o.run() + elect = ElectricalDesign(base) + elect.run() floating = deepcopy(base) floating["substation_design"]["oss_substructure_type"] = "Floating" - o_floating = ElectricalDesign(floating) - o_floating.run() + elect_floating = ElectricalDesign(floating) + elect_floating.run() - assert len(o.detailed_output) == len(o_floating.detailed_output) + assert len(elect.detailed_output) == len(elect_floating.detailed_output) def test_calc_substructure_mass_and_cost(): - o = ElectricalDesign(base) - o.run() + elect = ElectricalDesign(base) + elect.run() floating = deepcopy(base) floating["substation_design"]["oss_substructure_type"] = "Floating" - o_floating = ElectricalDesign(floating) - o_floating.run() + elect_floating = ElectricalDesign(floating) + elect_floating.run() assert ( - o.detailed_output["substation_substructure_cost"] - != o_floating.detailed_output["substation_substructure_cost"] + elect.detailed_output["substation_substructure_cost"] + != elect_floating.detailed_output["substation_substructure_cost"] ) assert ( - o.detailed_output["substation_substructure_mass"] - != o_floating.detailed_output["substation_substructure_mass"] + elect.detailed_output["substation_substructure_mass"] + != elect_floating.detailed_output["substation_substructure_mass"] ) def test_calc_topside_mass_and_cost(): """Test topside mass and cost for HVDC compared to HVDC-Monopole and HVDC-Bipole""" - o = ElectricalDesign(base) - o.run() + elect = ElectricalDesign(base) + elect.run() base_dc = deepcopy(base) cables = ["HVDC_2000mm_320kV", "HVDC_2500mm_525kV"] @@ -107,16 +113,16 @@ def test_calc_topside_mass_and_cost(): for cable in cables: base_dc["export_system_design"]["cables"] = cable - o_dc = ElectricalDesign(base_dc) - o_dc.run() + elect_dc = ElectricalDesign(base_dc) + elect_dc.run() assert ( - o.detailed_output["substation_topside_mass"] - == o_dc.detailed_output["substation_topside_mass"] + elect.detailed_output["substation_topside_mass"] + == elect_dc.detailed_output["substation_topside_mass"] ) assert ( - o.detailed_output["substation_topside_cost"] - != o_dc.detailed_output["substation_topside_cost"] + elect.detailed_output["substation_topside_cost"] + != elect_dc.detailed_output["substation_topside_cost"] ) @@ -128,20 +134,20 @@ def test_oss_substructure_kwargs(): "num_substations": 4, } - o = ElectricalDesign(base) - o.run() - base_cost_total = o.detailed_output["total_substation_cost"] - base_cost_subst = o.detailed_output["substation_substructure_cost"] + elect = ElectricalDesign(base) + elect.run() + base_cost_total = elect.detailed_output["total_substation_cost"] + base_cost_subst = elect.detailed_output["substation_substructure_cost"] for k, v in test_kwargs.items(): config = deepcopy(base) config["substation_design"] = {} config["substation_design"][k] = v - o = ElectricalDesign(config) - o.run() - cost_total = o.detailed_output["total_substation_cost"] - cost_subst = o.detailed_output["substation_substructure_cost"] + elect = ElectricalDesign(config) + elect.run() + cost_total = elect.detailed_output["total_substation_cost"] + cost_subst = elect.detailed_output["substation_substructure_cost"] assert cost_total != base_cost_total assert cost_subst != base_cost_subst @@ -161,18 +167,18 @@ def test_ac_oss_kwargs(): "num_substations": 4, } - o = ElectricalDesign(base) - o.run() - base_cost = o.detailed_output["total_substation_cost"] + elect = ElectricalDesign(base) + elect.run() + base_cost = elect.detailed_output["total_substation_cost"] for k, v in test_kwargs.items(): config = deepcopy(base) config["substation_design"] = {} config["substation_design"][k] = v - o = ElectricalDesign(config) - o.run() - cost = o.detailed_output["total_substation_cost"] + elect = ElectricalDesign(config) + elect.run() + cost = elect.detailed_output["total_substation_cost"] print("passed") assert cost != base_cost @@ -182,9 +188,9 @@ def test_dc_oss_kwargs(): dc_base = deepcopy(base) dc_base["export_system_design"]["cables"] = "HVDC_2000mm_320kV" - o = ElectricalDesign(dc_base) - o.run() - base_cost = o.detailed_output["total_substation_cost"] + elect = ElectricalDesign(dc_base) + elect.run() + base_cost = elect.detailed_output["total_substation_cost"] for k, v in test_kwargs.items(): config = deepcopy(base) @@ -192,9 +198,9 @@ def test_dc_oss_kwargs(): config["substation_design"] = {} config["substation_design"][k] = v - o = ElectricalDesign(config) - o.run() - cost = o.detailed_output["total_substation_cost"] + elect = ElectricalDesign(config) + elect.run() + cost = elect.detailed_output["total_substation_cost"] assert cost != base_cost @@ -232,35 +238,35 @@ def test_new_old_hvac_substation(): def test_hvdc_substation(): config = deepcopy(base) config["export_system_design"] = {"cables": "HVDC_2000mm_320kV"} - o = ElectricalDesign(config) - o.run() - assert o.converter_cost != 0 - assert o.shunt_reactor_cost == 0 - assert o.dc_breaker_cost != 0 - assert o.switchgear_cost == 0 - assert o.mpt_cost == 0 - # assert o.num_cables / o.num_converters == 2 # breaks + elect = ElectricalDesign(config) + elect.run() + assert elect.converter_cost != 0 + assert elect.shunt_reactor_cost == 0 + assert elect.dc_breaker_cost != 0 + assert elect.switchgear_cost == 0 + assert elect.mpt_cost == 0 + # assert elect.num_cables / elect.num_converters == 2 # breaks config = deepcopy(base) config["export_system_design"] = {"cables": "HVDC_2500mm_525kV"} - o = ElectricalDesign(config) - o.run() + elect = ElectricalDesign(config) + elect.run() - # assert o.num_converters == o.num_cables # breaks + # assert elect.num_converters == elect.num_cables # breaks def test_onshore_substation(): config = deepcopy(base) - o = ElectricalDesign(config) - o.run() - assert o.onshore_cost == pytest.approx(95.487e6, abs=1e2) # 109.32e6 + elect = ElectricalDesign(config) + elect.run() + assert elect.onshore_cost == pytest.approx(95.487e6, abs=1e2) # 109.32e6 config_mono = deepcopy(config) config_mono["export_system_design"] = {"cables": "HVDC_2000mm_320kV"} - o_mono = ElectricalDesign(config_mono) - o_mono.run() - assert o_mono.onshore_cost == 244.3e6 + o_monelect = ElectricalDesign(config_mono) + o_monelect.run() + assert o_monelect.onshore_cost == 244.3e6 config_bi = deepcopy(config) config_bi["export_system_design"] = {"cables": "HVDC_2500mm_525kV"} @@ -280,18 +286,18 @@ def test_export_kwargs(): # "interconnection_distance": 6, } - o = ElectricalDesign(base) - o.run() - base_cost = o.total_cost + elect = ElectricalDesign(base) + elect.run() + base_cost = elect.total_cost for k, v in test_kwargs.items(): config = deepcopy(base) config["export_system_design"] = {"cables": "XLPE_630mm_220kV"} config["export_system_design"][k] = v - o = ElectricalDesign(config) - o.run() - cost = o.total_cost + elect = ElectricalDesign(config) + elect.run() + cost = elect.total_cost assert cost != base_cost diff --git a/tests/phases/design/test_mooring_system_design.py b/tests/phases/design/test_mooring_system_design.py index 93fb714b..bf0e7021 100644 --- a/tests/phases/design/test_mooring_system_design.py +++ b/tests/phases/design/test_mooring_system_design.py @@ -29,11 +29,11 @@ def test_depth_sweep(depth): config = deepcopy(base) config["site"]["depth"] = depth - m = MooringSystemDesign(config) - m.run() + moor = MooringSystemDesign(config) + moor.run() - assert m.design_result - assert m.total_cost + assert moor.design_result + assert moor.total_cost @pytest.mark.parametrize("rating", range(3, 15, 1)) @@ -42,11 +42,29 @@ def test_rating_sweep(rating): config = deepcopy(base) config["turbine"]["turbine_rating"] = rating - m = MooringSystemDesign(config) - m.run() + moor = MooringSystemDesign(config) + moor.run() - assert m.design_result - assert m.total_cost + assert moor.design_result + assert moor.total_cost + + +def test_mooring_system_defaults(): + + moor_base = MooringSystemDesign(base) + moor_base.run() + + base_cost = moor_base.detailed_output["system_cost"] + + config_defs = deepcopy(base) + config_defs["mooring_system_design"] = {} + config_defs["mooring_system_design"]["mooring_type"] = "Catenary" + config_defs["mooring_system_design"]["anchor_type"] = "Suction Pile" + + moor_defs = MooringSystemDesign(config_defs) + moor_defs.run() + + assert moor_defs.detailed_output["system_cost"] == base_cost def test_catenary_mooring_system_kwargs(): @@ -57,20 +75,20 @@ def test_catenary_mooring_system_kwargs(): "mooring_line_cost_rate": 2500, } - m = MooringSystemDesign(base) - m.run() + moor = MooringSystemDesign(base) + moor.run() - base_cost = m.detailed_output["system_cost"] + base_cost = moor.detailed_output["system_cost"] for k, v in test_kwargs.items(): config = deepcopy(base) config["mooring_system_design"] = {} config["mooring_system_design"][k] = v - m = MooringSystemDesign(config) - m.run() + moor = MooringSystemDesign(config) + moor.run() - assert m.detailed_output["system_cost"] != base_cost + assert moor.detailed_output["system_cost"] != base_cost def test_semitaut_mooring_system_kwargs(): @@ -85,20 +103,20 @@ def test_semitaut_mooring_system_kwargs(): "rope_density": 1000, } - m = MooringSystemDesign(semi_base) - m.run() + moor = MooringSystemDesign(semi_base) + moor.run() - base_cost = m.detailed_output["system_cost"] + base_cost = moor.detailed_output["system_cost"] for k, v in test_kwargs.items(): config = deepcopy(semi_base) config["mooring_system_design"] = {} config["mooring_system_design"][k] = v - m = MooringSystemDesign(config) - m.run() + moor = MooringSystemDesign(config) + moor.run() - assert m.detailed_output["system_cost"] != base_cost + assert moor.detailed_output["system_cost"] != base_cost def test_tlp_mooring_system_kwargs(): @@ -113,36 +131,36 @@ def test_tlp_mooring_system_kwargs(): "draft_depth": 10, } - m = MooringSystemDesign(tlp_base) - m.run() + moor = MooringSystemDesign(tlp_base) + moor.run() - base_cost = m.detailed_output["system_cost"] + base_cost = moor.detailed_output["system_cost"] for k, v in test_kwargs.items(): config = deepcopy(tlp_base) config["mooring_system_design"] = {} config["mooring_system_design"][k] = v - m = MooringSystemDesign(config) - m.run() + moor = MooringSystemDesign(config) + moor.run() - assert m.detailed_output["system_cost"] != base_cost + assert moor.detailed_output["system_cost"] != base_cost def test_drag_embedment_fixed_length(): - m = MooringSystemDesign(base) - m.run() + moor = MooringSystemDesign(base) + moor.run() - baseline = m.line_length + baseline = moor.line_length default = deepcopy(base) default["mooring_system_design"] = {"anchor_type": "Drag Embedment"} - m = MooringSystemDesign(default) - m.run() + moor = MooringSystemDesign(default) + moor.run() - with_default = m.line_length + with_default = moor.line_length assert with_default > baseline custom = deepcopy(base) @@ -151,11 +169,11 @@ def test_drag_embedment_fixed_length(): "drag_embedment_fixed_length": 1000, } - m = MooringSystemDesign(custom) - m.run() + moor = MooringSystemDesign(custom) + moor.run() - assert m.line_length > with_default - assert m.line_length > baseline + assert moor.line_length > with_default + assert moor.line_length > baseline def test_custom_num_lines(): @@ -163,10 +181,10 @@ def test_custom_num_lines(): config = deepcopy(base) config["mooring_system_design"] = {"num_lines": 5} - m = MooringSystemDesign(config) - m.run() + moor = MooringSystemDesign(config) + moor.run() - assert m.design_result["mooring_system"]["num_lines"] == 5 + assert moor.design_result["mooring_system"]["num_lines"] == 5 def test_new_old_semitaut_mooring_system():