Example #1
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(
                f"The following columns must be included in the location 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(
                f"The provided number of turbines ({self.location_data.shape[0]}) ",
                f"does not match the plant 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
Example #2
0
    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.
        self.cables = OrderedDict()
        for name, specs in cables.items():
            specs = {"name": name, **specs}
            self.cables[name] = Cable(specs)
Example #3
0
    def __init__(self, config, **kwargs):
        """
        Creates an instance of ProjectDevelopment.

        Parameters
        ----------
        config : dict
        """

        config = self.initialize_library(config, **kwargs)
        self.config = self.validate_config(config)
        self._outputs = {}

        self.defaults = extract_library_specs("defaults", "project")
Example #4
0
def test_defaults():

    for k, _ in base["project_development"].items():

        _config = deepcopy(base)
        _config["project_development"].pop(k)

        dev = ProjectDevelopment(_config, library_path=pytest.library)
        dev.run()

        defaults = extract_library_specs("defaults", "project")

        _split = k.split("_")
        n = "_".join(_split[:-1])
        t = _split[-1]
        val = dev._outputs[n][t]
        assert val == defaults[k]
"""

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

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.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.tons_per_substructure


@pytest.mark.parametrize("weather", (None, test_weather),
                         ids=["no_weather", "test_weather"])
Example #6
0
def cable_vessel():

    specs = extract_library_specs("array_cable_install_vessel",
                                  "test_cable_lay_vessel")
    return Vessel("Test Cable Vessel", specs)
Example #7
0
"""Tests for the `OffshoreSubstationInstallation` class using feeder barges."""

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

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.orbit.phases.install import OffshoreSubstationInstallation

config_single = extract_library_specs("config", "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
    assert sim.port
Example #8
0
    def extract_defaults(self):
        """
        Extracts the default data from the library.
        """

        self.defaults = extract_library_specs("defaults", "project")
Example #9
0
__email__ = "*****@*****.**"


from copy import deepcopy

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import initialize_library, extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.orbit.phases.install import ArrayCableInstallation

initialize_library(pytest.library)

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"]
Example #10
0
__maintainer__ = "Rob Hammond"
__email__ = "*****@*****.**"

import os
from copy import deepcopy

import numpy as np
import pytest

from wisdem.orbit.library import initialize_library, extract_library_specs
from wisdem.orbit.phases.design import ArraySystemDesign, CustomArraySystemDesign
from wisdem.orbit.core.exceptions import LibraryItemNotFoundError

initialize_library(pytest.library)

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
Example #11
0
def feeder():

    specs = extract_library_specs("feeder", "test_feeder")
    return Vessel("Test Feeder", specs)
"""Tests for the `ExportSystemDesign` class."""

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

import pytest

from wisdem.orbit.library import extract_library_specs
from wisdem.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)
    export.run()
Example #13
0
import pandas as pd
import pytest

from wisdem.orbit import ProjectManager
from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import initialize_library, extract_library_specs
from wisdem.orbit.core.exceptions import (
    MissingInputs,
    PhaseNotFound,
    WeatherProfileError,
)

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

initialize_library(pytest.library)
config = extract_library_specs("config", "project_manager")


def test_for_required_phase_structure():
    """
    Automated integration test to verify that all classes listed in
    ProjectManager.possible_phases are structured correctly.
    """

    for p in ProjectManager._install_phases:

        assert isinstance(p.expected_config, dict)

    for p in ProjectManager._design_phases:

        assert isinstance(p.expected_config, dict)
Example #14
0
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import initialize_library, extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.orbit.phases.install import MonopileInstallation

initialize_library(pytest.library)
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
Example #15
0
__author__ = "Jake Nunemaker"
__copyright__ = "Copyright 2020, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.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.number_systems


@pytest.mark.parametrize("weather", (None, test_weather),
                         ids=["no_weather", "test_weather"])
def test_full_run_logging(weather):
Example #16
0
def heavy_lift():

    specs = extract_library_specs("oss_install_vessel",
                                  "test_heavy_lift_vessel")
    return Vessel("Test Heavy Vessel", specs)
Example #17
0
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import initialize_library, extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.orbit.phases.install import ExportCableInstallation

initialize_library(pytest.library)

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
Example #18
0
def spi_vessel():

    specs = extract_library_specs("spi_vessel", "test_scour_protection_vessel")
    return Vessel("Test SPI Vessel", specs)
Example #19
0
import pytest

from wisdem.orbit import ProjectManager
from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import extract_library_specs
from wisdem.orbit.manager import ProjectProgress
from wisdem.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_project()

    actions = pd.DataFrame(project.project_actions)

    phases = ["MonopileInstallation", "TurbineInstallation"]
    assert all(p in list(actions["phase"]) for p in phases)

Example #20
0
"""Tests for the `GravityBasedInstallation` 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 wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import extract_library_specs
from wisdem.orbit.phases.install import GravityBasedInstallation

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


def test_simulation_setup():

    sim = GravityBasedInstallation(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"]
    )
Example #21
0
def test_extract_library_specs_fail():
    library.initialize_library(pytest.library)
    with pytest.raises(LibraryItemNotFoundError):
        library.extract_library_specs("turbine", "unknown.yaml")
Example #22
0
__author__ = "Jake Nunemaker"
__copyright__ = "Copyright 2019, National Renewable Energy Laboratory"
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.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


@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 = TurbineInstallation(config)
Example #23
0
__maintainer__ = "Jake Nunemaker"
__email__ = "*****@*****.**"

from copy import deepcopy

import numpy as np
import pandas as pd
import pytest

from wisdem.test.test_orbit.data import test_weather
from wisdem.orbit.library import initialize_library, extract_library_specs
from wisdem.orbit.core._defaults import process_times as pt
from wisdem.orbit.phases.install import TurbineInstallation

initialize_library(pytest.library)
config_wtiv = extract_library_specs("config", "turbine_install_wtiv")
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


@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 = TurbineInstallation(config)
    assert sim.config == config
    assert sim.env
Example #24
0
def wtiv():

    specs = extract_library_specs("wtiv", "test_wtiv")
    return Vessel("Test WTIV", specs)