예제 #1
0
파일: _cables.py 프로젝트: WISDEM/ORBIT
    def _initialize_cables(self):
        """
        Creates the base cable objects for each type of array cable being used.
        """

        if isinstance(self._design["cables"], str):
            self._design["cables"] = [self._design["cables"]]
        if isinstance(self._design["cables"], list):
            _cables = {}
            for name in self._design["cables"]:
                _cables[name] = extract_library_specs("cables", name)
            self._design["cables"] = _cables

        _cables = {}
        for name, cable in self._design["cables"].items():
            cable.setdefault("name", name)
            _cables[name] = cable
        self._design["cables"] = _cables

        # Cables are ordered from smallest to largest
        cables = OrderedDict(
            sorted(
                self._design["cables"].items(),
                key=lambda item: item[1]["current_capacity"],
            ))

        # Instantiate cables as Cable objects. Use "name" property from file
        # instead of filename.
        self.cables = OrderedDict()
        for specs in cables.values():
            name = specs["name"]
            self.cables[name] = Cable(specs)
예제 #2
0
__author__ = "Jake Nunemaker"
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

import os

import pytest

from ORBIT import ProjectManager, load_config, save_config
from ORBIT.core.library import extract_library_specs

complete_project = extract_library_specs("config", "complete_project")


def test_save_and_load_equality(tmp_yaml_del):

    save_config(complete_project, "tmp.yaml", overwrite=True)
    new = load_config("tmp.yaml")

    assert new == complete_project


def test_orbit_version_ProjectManager():

    config = ProjectManager.compile_input_dict(
        ["MonopileDesign", "MonopileInstallation"])
    assert "orbit_version" in config.keys()
예제 #3
0
from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import (
    FloatingSubstationInstallation,
    OffshoreSubstationInstallation,
)
from ORBIT.core.exceptions import MissingComponent

config_single = extract_library_specs("config", "oss_install")
config_floating = extract_library_specs("config", "floating_oss_install")
config_multi = extract_library_specs("config", "oss_install")
config_multi["num_feeders"] = 2


@pytest.mark.parametrize(
    "config",
    (config_single, config_multi),
    ids=["single_feeder", "multi_feeder"],
)
def test_simulation_setup(config):

    sim = OffshoreSubstationInstallation(config)
    assert sim.config == config
    assert sim.env
예제 #4
0
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import ExportCableInstallation

base_config = extract_library_specs("config", "export_cable_install")
simul_config = deepcopy(base_config)
_ = simul_config.pop("export_cable_bury_vessel")


@pytest.mark.parametrize("config", (base_config, simul_config),
                         ids=["separate", "simultaneous"])
def test_simulation_setup(config):

    sim = ExportCableInstallation(config)
    assert sim.env
    assert sim.cable
    assert sim.cable.linear_density

    actions = [a["action"] for a in sim.env.actions]
    assert "Onshore Construction" in actions
예제 #5
0
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import MonopileInstallation

config_wtiv = extract_library_specs("config", "single_wtiv_mono_install")
config_wtiv_feeder = extract_library_specs("config", "multi_wtiv_mono_install")
config_wtiv_multi_feeder = deepcopy(config_wtiv_feeder)
config_wtiv_multi_feeder["num_feeders"] = 2


@pytest.mark.parametrize(
    "config",
    (config_wtiv, config_wtiv_feeder, config_wtiv_multi_feeder),
    ids=["wtiv_only", "single_feeder", "multi_feeder"],
)
def test_simulation_setup(config):

    sim = MonopileInstallation(config)
    assert sim.config == config
    assert sim.env
__author__ = "Jake Nunemaker"
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

from numpy.testing import assert_almost_equal

from ORBIT import ProjectManager
from ORBIT.core.library import extract_library_specs

fixed = extract_library_specs("config", "complete_project")
floating = extract_library_specs("config", "complete_floating_project")


def test_fixed_phase_cost_passing():

    project = ProjectManager(fixed)
    project.run()

    assert_almost_equal(
        project.phases["MonopileDesign"].total_cost,
        project.phases["MonopileInstallation"].system_capex,
    )

    assert_almost_equal(
        project.phases["ScourProtectionDesign"].total_cost,
        project.phases["ScourProtectionInstallation"].system_capex,
    )
예제 #7
0
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.manager import ProjectProgress
from ORBIT.core.library import extract_library_specs
from ORBIT.core.exceptions import (
    MissingInputs,
    PhaseNotFound,
    WeatherProfileError,
    PhaseDependenciesInvalid,
)

weather_df = pd.DataFrame(test_weather).set_index("datetime")

config = extract_library_specs("config", "project_manager")
complete_project = extract_library_specs("config", "complete_project")


### Top Level
@pytest.mark.parametrize("weather", (None, weather_df))
def test_complete_run(weather):

    project = ProjectManager(config, weather=weather)
    project.run()

    actions = pd.DataFrame(project.actions)

    phases = ["MonopileInstallation", "TurbineInstallation"]
    assert all(p in list(actions["phase"]) for p in phases)
예제 #8
0
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import ArrayCableInstallation

base_config = extract_library_specs("config", "array_cable_install")
simul_config = deepcopy(base_config)
_ = simul_config.pop("array_cable_bury_vessel")


@pytest.mark.parametrize("config", (base_config, simul_config),
                         ids=["separate", "simultaneous"])
def test_simulation_setup(config):

    sim = ArrayCableInstallation(config)
    assert sim.env


@pytest.mark.parametrize("config", (base_config, simul_config),
                         ids=["separate", "simultaneous"])
def test_vessel_initialization(config):
예제 #9
0
def spi_vessel():

    specs = extract_library_specs("spi_vessel", "test_scour_protection_vessel")
    return Vessel("Test SPI Vessel", specs)
예제 #10
0
def heavy_lift():

    specs = extract_library_specs(
        "oss_install_vessel", "test_heavy_lift_vessel"
    )
    return Vessel("Test Heavy Vessel", specs)
예제 #11
0
def cable_vessel():

    specs = extract_library_specs(
        "array_cable_install_vessel", "test_cable_lay_vessel"
    )
    return Vessel("Test Cable Vessel", specs)
예제 #12
0
def feeder():

    specs = extract_library_specs("feeder", "test_feeder")
    return Vessel("Test Feeder", specs)
예제 #13
0
def wtiv():

    specs = extract_library_specs("wtiv", "test_wtiv")
    return Vessel("Test WTIV", specs)
예제 #14
0
def test_extract_library_specs_fail():
    library.initialize_library(pytest.library)
    with pytest.raises(LibraryItemNotFoundError):
        library.extract_library_specs("turbine", "unknown.yaml")
예제 #15
0
"""Tests for the `MooredSubInstallation` class and related infrastructure."""

__author__ = "Jake Nunemaker"
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

import pandas as pd
import pytest

from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.phases.install import MooredSubInstallation

config = extract_library_specs("config", "moored_install")
no_supply = extract_library_specs("config", "moored_install_no_supply")


def test_simulation_setup():

    sim = MooredSubInstallation(config)
    assert sim.config == config
    assert sim.env

    assert sim.support_vessel
    assert len(sim.sub_assembly_lines) == config["port"]["sub_assembly_lines"]
    assert (len(sim.turbine_assembly_lines) == config["port"]
            ["turbine_assembly_cranes"])
    assert (len(sim.installation_groups) == config["towing_vessel_groups"]
            ["num_groups"])
    assert sim.num_turbines == config["plant"]["num_turbines"]
예제 #16
0
    def _initialize_custom_data(self):
        windfarm = self.config["array_system_design"]["location_data"]

        self.location_data = extract_library_specs(
            "cables", windfarm, file_type="csv"
        )

        # Make sure no data is missing
        missing = set(self.COLUMNS).difference(self.location_data.columns)
        if missing:
            raise ValueError(
                "The following columns must be included in the location ",
                f"data: {missing}",
            )

        self._format_windfarm_data()

        # Ensure there is no missing data in required columns
        missing_data_cols = [
            c
            for c in self.REQUIRED
            if pd.isnull(self.location_data[c]).sum() > 0
        ]
        if missing_data_cols:
            raise ValueError(f"Missing data in columns: {missing_data_cols}!")

        # Ensure there is no missing data in optional columns
        missing_data_cols = [
            c
            for c in self.OPTIONAL
            if (
                pd.isnull(self.location_data[c]) | self.location_data[c] == 0
            ).sum()
            > 0
        ]
        if missing_data_cols:
            message = (
                f"Missing data in columns {missing_data_cols}; "
                "all values will be calculated."
            )
            warnings.warn(message)

        # Ensure the number of turbines matches what's expected
        if self.location_data.shape[0] != self.system.num_turbines:
            raise ValueError(
                "The provided number of turbines ",
                f"({self.location_data.shape[0]}) does not match the plant ",
                f"data ({self.system.num_turbines}).",
            )

        n_coords = self.location_data.groupby(
            ["turbine_latitude", "turbine_longitude"]
        ).ngroups
        duplicates = self.location_data.shape[0] - n_coords
        if duplicates > 0:
            raise ValueError(
                f"There are {duplicates} rows with duplicate coordinates."
            )

        # Ensure the number of turbines on a string is within the limits
        longest_string = self.location_data["order"].unique().size
        self.num_strings = self.location_data.groupby(
            ["substation_id", "string"]
        ).ngroups
        if longest_string > self.num_turbines_full_string:
            raise ValueError(
                "Strings can't contain more than "
                f"{self.num_turbines_full_string} turbines."
            )
        else:
            self.num_turbines_full_string = longest_string
            del self.num_turbines_partial_string
            del self.num_partial_strings
예제 #17
0
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"


from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import MooringSystemInstallation

config = extract_library_specs("config", "mooring_system_install")


def test_simulation_creation():
    sim = MooringSystemInstallation(config)

    assert sim.config == config
    assert sim.env
    assert sim.port
    assert sim.vessel
    assert sim.num_systems


@pytest.mark.parametrize(
    "weather", (None, test_weather), ids=["no_weather", "test_weather"]
)
예제 #18
0
__author__ = "Rob Hammond"
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Rob Hammond"
__email__ = "*****@*****.**"

from copy import deepcopy

import numpy as np
import pytest

from ORBIT.core.library import extract_library_specs
from ORBIT.phases.design import ArraySystemDesign, CustomArraySystemDesign
from ORBIT.core.exceptions import LibraryItemNotFoundError

config_full_ring = extract_library_specs("config", "array_design_full_ring")

config_partial_ring = deepcopy(config_full_ring)
config_partial_ring["plant"]["num_turbines"] = 49

config_full_grid = deepcopy(config_full_ring)
config_full_grid["plant"]["layout"] = "grid"

config_partial_grid = deepcopy(config_full_grid)
config_partial_grid["plant"]["num_turbines"] = 49

config_cables_from_file_fail = deepcopy(config_full_grid)
config_cables_from_file_fail["array_system_design"]["cables"] = "Cable1"

config_custom_base = deepcopy(config_full_grid)
config_custom_base["plant"]["num_turbines"] = 8
예제 #19
0
__copyright__ = "Copyright 2019, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import TurbineInstallation

config_wtiv = extract_library_specs("config", "turbine_install_wtiv")
config_long_mobilize = extract_library_specs("config",
                                             "turbine_install_long_mobilize")
config_wtiv_feeder = extract_library_specs("config", "turbine_install_feeder")
config_wtiv_multi_feeder = deepcopy(config_wtiv_feeder)
config_wtiv_multi_feeder["num_feeders"] = 2
floating = extract_library_specs("config", "floating_turbine_install_feeder")


@pytest.mark.parametrize(
    "config",
    (config_wtiv, config_wtiv_feeder, config_wtiv_multi_feeder, floating),
    ids=["wtiv_only", "single_feeder", "multi_feeder", "floating"],
)
def test_simulation_setup(config):
예제 #20
0
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"


from copy import deepcopy

import pandas as pd
import pytest

from ORBIT import ProjectManager
from tests.data import test_weather
from ORBIT.core.library import extract_library_specs
from ORBIT.core.defaults import process_times as pt
from ORBIT.phases.install import ScourProtectionInstallation

config = extract_library_specs("config", "scour_protection_install")


def test_simulation_creation():
    sim = ScourProtectionInstallation(config)

    assert sim.config == config
    assert sim.env
    assert sim.port
    assert sim.spi_vessel
    assert sim.num_turbines
    assert sim.tonnes_per_substructure


@pytest.mark.parametrize(
    "weather", (None, test_weather), ids=["no_weather", "test_weather"]
예제 #21
0
"""Tests for the `ExportSystemDesign` class."""

__author__ = "Rob Hammond"
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Rob Hammond"
__email__ = "*****@*****.**"

from copy import deepcopy

import pytest

from ORBIT.core.library import extract_library_specs
from ORBIT.phases.design import ExportSystemDesign

config = extract_library_specs("config", "export_design")


def test_export_system_creation():
    export = ExportSystemDesign(config)
    export.run()

    assert export.num_cables
    assert export.length
    assert export.mass
    assert export.cable
    assert export.total_length
    assert export.total_mass


def test_number_cables():
    export = ExportSystemDesign(config)