Skip to content

Commit 1653322

Browse files
Merge pull request #133 from WISDEM/dev
v1.0.8 Release
2 parents f8d6ac4 + e88297e commit 1653322

File tree

12 files changed

+192
-31
lines changed

12 files changed

+192
-31
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ci:
2+
skip: [isort, black, pylint]
3+
14
repos:
25
- repo: https://github.com/timothycrosley/isort
36
rev: 4.3.21

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 Alliance for Sustainable Energy, LLC
1+
Copyright (c) 2020 Alliance for Sustainable Energy, LLC
22

33
Apache License
44
Version 2.0, January 2004

ORBIT/core/cargo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Cargo(Object):
9-
9+
1010
def __repr__(self):
1111
return self.type
1212

ORBIT/manager.py

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ProjectManager:
6161
date_format_short = "%m/%d/%Y"
6262
date_format_long = "%m/%d/%Y %H:%M"
6363

64-
_design_phases = [
64+
_design_phases = (
6565
MonopileDesign,
6666
ArraySystemDesign,
6767
CustomArraySystemDesign,
@@ -71,9 +71,9 @@ class ProjectManager:
7171
MooringSystemDesign,
7272
SemiSubmersibleDesign,
7373
SparDesign,
74-
]
74+
)
7575

76-
_install_phases = [
76+
_install_phases = (
7777
MonopileInstallation,
7878
TurbineInstallation,
7979
OffshoreSubstationInstallation,
@@ -85,7 +85,7 @@ class ProjectManager:
8585
GravityBasedInstallation,
8686
FloatingSubstationInstallation,
8787
JacketInstallation,
88-
]
88+
)
8989

9090
def __init__(self, config, library_path=None, weather=None):
9191
"""
@@ -188,6 +188,54 @@ def phases(self):
188188

189189
return self._phases
190190

191+
@classmethod
192+
def register_design_phase(cls, phase):
193+
"""
194+
Add a custom design phase to the `ProjectManager` class.
195+
196+
Parameters
197+
----------
198+
phase : ORBIT.phases.DesignPhase
199+
"""
200+
201+
if not issubclass(phase, DesignPhase):
202+
raise ValueError(
203+
"Registered design phase must be a subclass of "
204+
"'ORBIT.phases.DesignPhase'."
205+
)
206+
207+
if phase.__name__ in [c.__name__ for c in cls._design_phases]:
208+
raise ValueError(f"A phase with name '{phase.__name__}' already exists.")
209+
210+
if len(re.split("[_ ]", phase.__name__)) > 1:
211+
raise ValueError(f"Registered phase name must not include a '_'.")
212+
213+
cls._design_phases = (*cls._design_phases, phase)
214+
215+
@classmethod
216+
def register_install_phase(cls, phase):
217+
"""
218+
Add a custom install phase to the `ProjectManager` class.
219+
220+
Parameters
221+
----------
222+
phase : ORBIT.phases.InstallPhase
223+
"""
224+
225+
if not issubclass(phase, InstallPhase):
226+
raise ValueError(
227+
"Registered install phase must be a subclass of "
228+
"'ORBIT.phases.InstallPhase'."
229+
)
230+
231+
if phase.__name__ in [c.__name__ for c in cls._install_phases]:
232+
raise ValueError(f"A phase with name '{phase.__name__}' already exists.")
233+
234+
if len(re.split("[_ ]", phase.__name__)) > 1:
235+
raise ValueError(f"Registered phase name must not include a '_'.")
236+
237+
cls._install_phases = (*cls._install_phases, phase)
238+
191239
@property
192240
def _capex_categories(self):
193241
"""Returns CapEx categories for phases in `self._install_phases`."""

ORBIT/phases/design/array_system_design.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import matplotlib.pyplot as plt
1515

1616
from ORBIT.core.library import export_library_specs, extract_library_specs
17+
from ORBIT.core.exceptions import LibraryItemNotFoundError
1718
from ORBIT.phases.design._cables import Plant, CableSystem
1819

1920

@@ -363,7 +364,7 @@ def run(self):
363364
self._create_wind_farm_layout()
364365
self._create_cable_section_lengths()
365366

366-
def save_layout(self, save_name, return_df=False):
367+
def save_layout(self, save_name, return_df=False, folder="cables"):
367368
"""Outputs a csv of the substation and turbine positional and cable
368369
related components.
369370
@@ -375,12 +376,23 @@ def save_layout(self, save_name, return_df=False):
375376
return_df : bool, optional
376377
If true, returns layout_df, a pandas.DataFrame of the cabling
377378
layout, by default False.
379+
folder : str, optional
380+
If "cables", then the layout will saved to the "cables" folder, and
381+
if "plant", then the layout will be saved to the "project/plant" folder.
378382
379383
Returns
380384
-------
381385
pd.DataFrame
382386
The DataFrame with the layout data.
387+
388+
Raises
389+
------
390+
ValueError
391+
Raised if ``folder`` is not one of "cables" or "plant".
383392
"""
393+
if folder not in ("cables", "plant"):
394+
raise ValueError("`folder` must be one of: 'cables' or plant'.")
395+
384396
num_turbines = self.system.num_turbines
385397
columns = [
386398
"id",
@@ -448,7 +460,7 @@ def save_layout(self, save_name, return_df=False):
448460
print(
449461
f"Saving custom array CSV to: <library_path>/cables/{save_name}.csv"
450462
)
451-
export_library_specs("cables", save_name, data, file_ext="csv")
463+
export_library_specs(folder, save_name, data, file_ext="csv")
452464
if return_df:
453465
return layout_df
454466

@@ -725,14 +737,21 @@ def __init__(self, config, distance=False, **kwargs):
725737
super().__init__(config, **kwargs)
726738
self.distance = config["array_system_design"].get("distance", distance)
727739

728-
def create_project_csv(self, save_name):
740+
def create_project_csv(self, save_name, folder="cables"):
729741
"""Creates a base CSV in <`library_path`>/cables/
730742
731743
Parameters
732744
----------
733745
save_name : [type]
734746
[description]
747+
748+
Raises
749+
------
750+
ValueError
751+
Raised if ``folder`` is not one of "cables" or "plant".
735752
"""
753+
if folder not in ("cables", "plant"):
754+
raise ValueError("`folder` must be one of: 'cables' or plant'.")
736755

737756
self._initialize_cables()
738757
self.create_strings()
@@ -792,7 +811,7 @@ def create_project_csv(self, save_name):
792811
print(
793812
f"Saving custom array CSV to: <library_path>/cables/{save_name}.csv"
794813
)
795-
export_library_specs("cables", save_name, rows, file_ext="csv")
814+
export_library_specs(folder, save_name, rows, file_ext="csv")
796815

797816
def _format_windfarm_data(self):
798817

@@ -843,16 +862,20 @@ def _format_windfarm_data(self):
843862
def _initialize_custom_data(self):
844863
windfarm = self.config["array_system_design"]["location_data"]
845864

846-
self.location_data = extract_library_specs(
847-
"cables", windfarm, file_type="csv"
848-
)
849-
865+
try:
866+
self.location_data = extract_library_specs(
867+
"cables", windfarm, file_type="csv"
868+
)
869+
except LibraryItemNotFoundError:
870+
self.location_data = extract_library_specs(
871+
"plant", windfarm, file_type="csv"
872+
)
850873
# Make sure no data is missing
851874
missing = set(self.COLUMNS).difference(self.location_data.columns)
852875
if missing:
853876
raise ValueError(
854-
"The following columns must be included in the location ",
855-
f"data: {missing}",
877+
"The following columns must be included in the location "
878+
f"data: {missing}"
856879
)
857880

858881
self._format_windfarm_data()
@@ -885,9 +908,9 @@ def _initialize_custom_data(self):
885908
# Ensure the number of turbines matches what's expected
886909
if self.location_data.shape[0] != self.system.num_turbines:
887910
raise ValueError(
888-
"The provided number of turbines ",
889-
f"({self.location_data.shape[0]}) does not match the plant ",
890-
f"data ({self.system.num_turbines}).",
911+
"The provided number of turbines "
912+
f"({self.location_data.shape[0]}) does not match the plant "
913+
f"data ({self.system.num_turbines})."
891914
)
892915

893916
n_coords = self.location_data.groupby(
@@ -1017,7 +1040,7 @@ def _create_windfarm_layout(self):
10171040
self.sections_bury_speeds[
10181041
string, order
10191042
] = data.bury_speed.values[order]
1020-
i += string + 1
1043+
i = string + 1
10211044

10221045
# Ensure any point in array without a turbine is set to None
10231046
no_turbines = self.location_data_x == 0

ORBIT/phases/install/oss_install/floating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def initialize_installation_vessel(self):
144144

145145
@property
146146
def detailed_output(self):
147-
147+
148148
return {}
149149

150150

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ORBIT
44
Offshore Renewables Balance of system and Installation Tool
55

66

7-
:Version: 1.0.7
7+
:Version: 1.0.8
88
:Authors: `Jake Nunemaker <https://www.linkedin.com/in/jake-nunemaker/>`_, `Matt Shields <https://www.linkedin.com/in/matt-shields-834a6b66/>`_, `Rob Hammond <https://www.linkedin.com/in/rob-hammond-33583756/>`_
99
:Documentation: `ORBIT Docs <https://wisdem.github.io/ORBIT/>`_
1010

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ help:
1616
# Catch-all target: route all unknown targets to Sphinx using the new
1717
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1818
%: Makefile
19-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/source/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
ORBIT Changelog
44
===============
55

6+
1.0.8
7+
-----
8+
9+
- Added explicit methods for adding custom design or install phases to
10+
ProjectManager.
11+
- Added WOMBAT compatibility for custom array system files.
12+
- Fixed bug in custom array cable system design that breaks for plants with
13+
more than two substations.
14+
615
1.0.7
716
-----
817

library/turbines/15MW_generic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ tower:
1717
type: Tower
1818
length: 150
1919
mass: 480 # t
20-
turbine_rating: 15 # MW
20+
turbine_rating: 15 # MW

0 commit comments

Comments
 (0)