def test_for_complete_installation(config): sim = TurbineInstallation(config) sim.run() installed_nacelles = len( [a for a in sim.env.actions if a["action"] == "Attach Nacelle"]) assert installed_nacelles == sim.num_turbines
def test_for_complete_logging(weather, config): sim = TurbineInstallation(config, weather=weather) sim.run() df = pd.DataFrame(sim.env.actions) df = df.assign(shift=(df["time"] - df["time"].shift(1))) for vessel in df["agent"].unique(): _df = df[df["agent"] == vessel].copy() _df = _df.assign(shift=(_df["time"] - _df["time"].shift(1))) assert (_df["shift"] - _df["duration"]).abs().max() < 1e-9 assert ~df["cost"].isnull().any() _ = sim.agent_efficiencies _ = sim.detailed_output
def test_individual_phase(): config = benedict(deepcopy(complete_project)) config["site.distance"] = 20 phase = TurbineInstallation(config) phase.run() funcs = {"time": lambda phase: phase.total_phase_time} parametric = ParametricManager(complete_project, params, funcs, module=TurbineInstallation) parametric.run() df = parametric.results.set_index("site.distance") assert df.loc[20]["time"] == phase.total_phase_time
def test_kwargs(): sim = TurbineInstallation(config_wtiv) sim.run() baseline = sim.total_phase_time keywords = [ "tower_section_fasten_time", "tower_section_release_time", "tower_section_attach_time", "nacelle_fasten_time", "nacelle_release_time", "nacelle_attach_time", "blade_fasten_time", "blade_release_time", "blade_attach_time", "site_position_time", "crane_reequip_time", ] failed = [] for kw in keywords: default = pt[kw] kwargs = {kw: default + 2} new_sim = TurbineInstallation(config_wtiv, **kwargs) new_sim.run() new_time = new_sim.total_phase_time if new_time > baseline: pass else: failed.append(kw) if failed: raise Exception(f"'{failed}' not affecting results.") else: assert True
def test_multiple_tower_sections(): sim = TurbineInstallation(config_wtiv) sim.run() baseline = len( [a for a in sim.env.actions if a["action"] == "Attach Tower Section"]) two_sections = deepcopy(config_wtiv) two_sections["turbine"]["tower"]["sections"] = 2 sim2 = TurbineInstallation(two_sections) sim2.run() new = len( [a for a in sim2.env.actions if a["action"] == "Attach Tower Section"]) assert new == 2 * baseline df = pd.DataFrame(sim.env.actions) for vessel in df["agent"].unique(): vl = df[df["agent"] == vessel].copy() vl = vl.assign(shift=(vl["time"] - vl["time"].shift(1))) assert (vl["shift"] - vl["duration"]).abs().max() < 1e-9