def test_duplicate_phase_definitions(): config_with_duplicates = deepcopy(config) config_with_duplicates["MonopileInstallation_1"] = { "plant": { "num_turbines": 5 } } config_with_duplicates["MonopileInstallation_2"] = { "plant": { "num_turbines": 5 }, "site": { "distance": 100 }, } config_with_duplicates["install_phases"] = { "MonopileInstallation_1": 0, "MonopileInstallation_2": 800, "TurbineInstallation": 1600, } project = ProjectManager(config_with_duplicates) project.run_project() df = (pd.DataFrame(project.project_actions).groupby(["phase", "action" ]).count()["time"]) assert df.loc[("MonopileInstallation_1", "Drive Monopile")] == 5 assert df.loc[("MonopileInstallation_2", "Drive Monopile")] == 5 assert df.loc[("TurbineInstallation", "Attach Tower Section")] == 10
def test_incomplete_config(): incomplete_config = deepcopy(config) _ = incomplete_config["site"].pop("depth") with pytest.raises(MissingInputs): project = ProjectManager(incomplete_config) project.run_project()
def test_wrong_phases(): wrong_phases = deepcopy(config) wrong_phases["install_phases"].append("IncorrectPhaseName") with pytest.raises(PhaseNotFound): project = ProjectManager(wrong_phases) project.run_project()
def instantiate_orbit(): ProjectManager.compile_input_dict(phases) path = os.path.join(os.getcwd(), "..\general_library") ORBIT_project = ProjectManager(config, weather=None, library_path=path) ORBIT_project.run_project() print('OSS', ORBIT_project._phases["OffshoreSubstationDesign"].design_result) return ORBIT_project
def test_complete_run(weather): project = ProjectManager(config, weather=weather) project.run_project() actions = pd.DataFrame(project.project_actions) phases = ["MonopileInstallation", "TurbineInstallation"] assert all(p in list(actions["phase"]) for p in phases)
def test_bad_dates(): bad_dates = deepcopy(config) bad_dates["install_phases"] = { "MonopileInstallation": "03/01/2015", "TurbineInstallation": "05/01/2015", } with pytest.raises(WeatherProfileError): project = ProjectManager(bad_dates, weather=weather_df) project.run_project()
def test_no_defined_start(): missing_start = deepcopy(config) missing_start["install_phases"] = { "MonopileInstallation": ("TurbineInstallation", 0.1), "TurbineInstallation": ("MonopileInstallation", 0.1), } with pytest.raises(ValueError): project = ProjectManager(missing_start) project.run_project()
def test_ProjectProgress_with_incomplete_project(): project = ProjectManager(config) project.run_project() _ = project.progress.parse_logs("Substructure") _ = project.progress.parse_logs("Turbine") with pytest.raises(ValueError): project.progress.complete_export_system with pytest.raises(ValueError): project.progress.complete_array_strings
def test_circular_dependencies(): circular_deps = deepcopy(config) circular_deps["spi_vessel"] = "test_scour_protection_vessel" circular_deps["scour_protection"] = {"tons_per_substructure": 200} circular_deps["install_phases"] = { "ScourProtectionInstallation": 0, "MonopileInstallation": ("TurbineInstallation", 0.1), "TurbineInstallation": ("MonopileInstallation", 0.1), } with pytest.raises(PhaseDependenciesInvalid): project = ProjectManager(circular_deps) project.run_project()
def test_monthly_expenses(): project = ProjectManager(complete_project) project.run_project() _ = project.monthly_expenses # Still report expenses for "incomplete" project config = deepcopy(complete_project) _ = config["install_phases"].pop("TurbineInstallation") project = ProjectManager(config) project.run_project() _ = project.monthly_expenses
def compute(self, inputs, outputs, discrete_inputs, discrete_outputs): config = self.compile_orbit_config_file(inputs, outputs, discrete_inputs, discrete_outputs) project = ProjectManager(config) project.run_project() outputs['bos_capex'] = project.bos_capex outputs['total_capex'] = project.total_capex outputs['total_capex_kW'] = project.total_capex_per_kw outputs['installation_time'] = project.installation_time outputs['installation_capex'] = project.installation_capex
def test_monthly_revenue(): project = ProjectManager(complete_project) project.run_project() _ = project.monthly_revenue # Can't generate revenue with "incomplete" project config = deepcopy(complete_project) _ = config["install_phases"].pop("TurbineInstallation") project = ProjectManager(config) project.run_project() with pytest.raises(ValueError): _ = project.monthly_revenue
def test_dependent_phase_ordering(): wrong_order = deepcopy(config) wrong_order["spi_vessel"] = "test_scour_protection_vessel" wrong_order["scour_protection"] = {"tons_per_substructure": 200} wrong_order["install_phases"] = { "ScourProtectionInstallation": ("TurbineInstallation", 0.1), "TurbineInstallation": ("MonopileInstallation", 0.1), "MonopileInstallation": 0, } project = ProjectManager(wrong_order) project.run_project() assert len(project.phase_times) == 3
def instantiate_orbit(config_start_date, config_year): """ Instantiate instance of ORBIT project for a given year within the time series""" ProjectManager.compile_input_dict(phases) path = os.path.join(os.getcwd(), "library") filepath = os.path.join('library', 'weather', 'ERA5_1979_2019.csv') weather = pd.read_csv(filepath, parse_dates=["datetime"]).set_index(keys='datetime') # Update config for specified start date config_date = config_start_date + '/' + config_year config['install_phases'] = {k: config_date for (k, v) in config['install_phases'].items()} # Run project ORBIT_project = ProjectManager(config, weather=weather, library_path=path) ORBIT_project.run_project() return ORBIT_project
def test_cash_flow(): project = ProjectManager(complete_project) project.run_project() _ = project.cash_flow # Can't generate revenue with "incomplete" project but cash flow will still # be reported config = deepcopy(complete_project) _ = config["install_phases"].pop("TurbineInstallation") project = ProjectManager(config) project.run_project() cash_flow = project.cash_flow assert all(v <= 0 for v in cash_flow.values())
def test_start_dates_with_weather(m_start, t_start, expected): config_with_defined_starts = deepcopy(config) config_with_defined_starts["install_phases"] = { "MonopileInstallation": m_start, "TurbineInstallation": t_start, } project = ProjectManager(config_with_defined_starts, weather=weather_df) project.run_project() df = pd.DataFrame(project.project_actions) _m = df.loc[df["phase"] == "MonopileInstallation"].iloc[0] _t = df.loc[df["phase"] == "TurbineInstallation"].iloc[0] _diff = (_t["time"] - _t["duration"]) - (_m["time"] - _m["duration"]) assert _diff == expected
def test_mono_and_tp_definition(): test_config = deepcopy(config) project = ProjectManager(test_config) project.run_project() for key, value in config["monopile"].items(): if key == "type": continue assert project.config["monopile"][key] == value for key, value in config["transition_piece"].items(): if key == "type": continue assert project.config["transition_piece"][key] == value
def test_phase_specific_definitions(): """ Tests that phase specific information makes it to phase_config. """ project = ProjectManager(config) phase_config = project.create_config_for_phase("MonopileInstallation") assert phase_config["wtiv"]["name"] == "Phase Specific WTIV" assert phase_config["site"]["distance"] == 500 phase_config = project.create_config_for_phase("TurbineInstallation") assert phase_config["wtiv"]["name"] == "Example WTIV" assert phase_config["site"]["distance"] == 50 project.run_project()
def test_index_starts(m_start, t_start): """ Tests functionality related to passing index starts into 'install_phases' sub-dict. """ _target_diff = t_start - m_start config_with_index_starts = deepcopy(config) config_with_index_starts["install_phases"] = { "MonopileInstallation": m_start, "TurbineInstallation": t_start, } project = ProjectManager(config_with_index_starts) project.run_project() df = pd.DataFrame(project.project_actions) _m = df.loc[df["phase"] == "MonopileInstallation"].iloc[0] _t = df.loc[df["phase"] == "TurbineInstallation"].iloc[0] _diff = (_t["time"] - _t["duration"]) - (_m["time"] - _m["duration"]) assert _diff == _target_diff
def test_chained_dependencies(): config_chained = deepcopy(config) config_chained["spi_vessel"] = "test_scour_protection_vessel" config_chained["scour_protection"] = {"tons_per_substructure": 200} config_chained["install_phases"] = { "ScourProtectionInstallation": 0, "MonopileInstallation": ("ScourProtectionInstallation", 0.1), "TurbineInstallation": ("MonopileInstallation", 0.5), } project = ProjectManager(config_chained) project.run_project() df = pd.DataFrame(project.project_actions) sp = list(df.loc[df["phase"] == "ScourProtectionInstallation"]["time"]) mp = list(df.loc[df["phase"] == "MonopileInstallation"]["time"]) tu = list(df.loc[df["phase"] == "TurbineInstallation"]["time"]) assert min(sp) == 0 assert min(mp) == (max(sp) - min(sp)) * 0.1 assert min(tu) == (max(mp) - min(mp)) * 0.5 + min(mp)
def test_design_phases(): config_with_design = deepcopy(config) # Add MonopileDesign config_with_design["design_phases"] = ["MonopileDesign"] # Add required parameters config_with_design["site"]["mean_windspeed"] = 9 config_with_design["turbine"]["rotor_diameter"] = 200 config_with_design["turbine"]["rated_windspeed"] = 10 config_with_design["monopile_design"] = {} # Remove monopile sub dictionary _ = config_with_design.pop("monopile") project = ProjectManager(config_with_design) project.run_project() assert isinstance(project.config["monopile"], dict) project = ProjectManager(config_with_design) project.run_project()
def test_ProjectProgress_with_complete_project(): project = ProjectManager(complete_project) project.run_project() _ = project.progress.parse_logs("Substructure") _ = project.progress.parse_logs("Turbine") _ = project.progress.parse_logs("Array String") _ = project.progress.parse_logs("Export System") _ = project.progress.parse_logs("Offshore Substation") _ = project.progress.complete_export_system _ = project.progress.complete_array_strings _ = project.progress.energize_points new = deepcopy(complete_project) new["plant"]["num_turbines"] = 61 # Uneven strings project = ProjectManager(new) project.run_project() _ = project.progress.energize_points
def test_npv(): project = ProjectManager(complete_project) project.run_project() baseline = project.npv config = deepcopy(complete_project) config["ncf"] = 0.35 project = ProjectManager(config) project.run_project() assert project.npv != baseline config = deepcopy(complete_project) config["offtake_price"] = 70 project = ProjectManager(config) project.run_project() assert project.npv != baseline config = deepcopy(complete_project) config["project_lifetime"] = 30 project = ProjectManager(config) project.run_project() assert project.npv != baseline config = deepcopy(complete_project) config["discount_rate"] = 0.03 project = ProjectManager(config) project.run_project() assert project.npv != baseline config = deepcopy(complete_project) config["opex_rate"] = 120 project = ProjectManager(config) project.run_project() assert project.npv != baseline