Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Address reference wind height warnings raised unnecessarily #1017

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
wind_speeds=wind_speeds,
turbulence_intensities=turbulence_intensities,
turbine_type=[turbine_dict],
reference_wind_height=fmodel.reference_wind_height
)
fmodel.run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
### Start by visualizing a single turbine in and its wake with the new model
# Load the new TurboPark implementation and switch to constant CT turbine
fmodel_new = FlorisModel("../inputs/turboparkgauss_cubature.yaml")
fmodel_new.set(turbine_type=[const_CT_turb])
fmodel_new.set(
turbine_type=[const_CT_turb],
reference_wind_height=fmodel_new.reference_wind_height
)
fmodel_new.run()
u0 = fmodel_new.wind_speeds[0]

Expand Down Expand Up @@ -94,7 +97,10 @@
### Look at the wake profile at a single downstream distance for a range of wind directions
# Load the original TurboPark implementation and switch to constant CT turbine
fmodel_orig = FlorisModel("../inputs/turbopark_cubature.yaml")
fmodel_orig.set(turbine_type=[const_CT_turb])
fmodel_orig.set(
turbine_type=[const_CT_turb],
reference_wind_height=fmodel_orig.reference_wind_height
)

# Set up and solve flows
wd_array = np.arange(225,315,0.1)
Expand Down
20 changes: 18 additions & 2 deletions floris/floris_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,10 @@ def set_operation_model(self, operation_model: str | List[str]):
# Set a single one here, then, and return
turbine_type = self.core.farm.turbine_definitions[0]
turbine_type["operation_model"] = operation_model
self.set(turbine_type=[turbine_type])
self.set(
turbine_type=[turbine_type],
reference_wind_height=self.reference_wind_height
)
return
else:
operation_model = [operation_model]*self.core.farm.n_turbines
Expand All @@ -1561,7 +1564,10 @@ def set_operation_model(self, operation_model: str | List[str]):
)
turbine_type_list[tindex]["operation_model"] = operation_model[tindex]

self.set(turbine_type=turbine_type_list)
self.set(
turbine_type=turbine_type_list,
reference_wind_height=self.reference_wind_height
)

def copy(self):
"""Create an independent copy of the current FlorisModel object"""
Expand Down Expand Up @@ -1702,6 +1708,16 @@ def n_turbines(self):
"""
return self.core.farm.n_turbines

@property
def reference_wind_height(self):
"""
Reference wind height.

Returns:
float: Reference wind height.
"""
return self.core.flow_field.reference_wind_height

@property
def turbine_average_velocities(self) -> NDArrayFloat:
return average_velocity(
Expand Down
3 changes: 2 additions & 1 deletion floris/flow_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ def calculate_horizontal_plane_with_turbines(
awc_modes=awc_modes,
awc_amplitudes=awc_amplitudes,
awc_frequencies=awc_frequencies,
turbine_type=turbine_types_test
turbine_type=turbine_types_test,
reference_wind_height=fmodel_viz.reference_wind_height
)
fmodel_viz.run()

Expand Down
20 changes: 18 additions & 2 deletions floris/uncertain_floris_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,10 @@ def set_operation_model(self, operation_model: str | List[str]):
# Set a single one here, then, and return
turbine_type = self.fmodel_unexpanded.core.farm.turbine_definitions[0]
turbine_type["operation_model"] = operation_model
self.set(turbine_type=[turbine_type])
self.set(
turbine_type=[turbine_type],
reference_wind_height=self.reference_wind_height
)
return
else:
operation_model = [operation_model] * self.fmodel_unexpanded.core.farm.n_turbines
Expand All @@ -976,7 +979,10 @@ def set_operation_model(self, operation_model: str | List[str]):
)
turbine_type_list[tindex]["operation_model"] = operation_model[tindex]

self.set(turbine_type=turbine_type_list)
self.set(
turbine_type=turbine_type_list,
reference_wind_height=self.reference_wind_height
)

def copy(self):
"""Create an independent copy of the current UncertainFlorisModel object"""
Expand Down Expand Up @@ -1095,6 +1101,16 @@ def n_turbines(self):
"""
return self.fmodel_unexpanded.core.farm.n_turbines

@property
def reference_wind_height(self):
"""
Reference wind height.

Returns:
float: Reference wind height.
"""
return self.fmodel_unexpanded.core.flow_field.reference_wind_height

@property
def core(self):
"""
Expand Down
12 changes: 7 additions & 5 deletions tests/floris_model_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,41 +720,43 @@ def test_set_operation_model():
fmodel.set_operation_model("simple-derating")
assert fmodel.get_operation_model() == "simple-derating"

reference_wind_height = fmodel.reference_wind_height

# Check multiple turbine types works
fmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
fmodel.set_operation_model(["simple-derating", "cosine-loss"])
assert fmodel.get_operation_model() == ["simple-derating", "cosine-loss"]

# Check that setting a single turbine type, and then altering the operation model works
fmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
fmodel.set(turbine_type=["nrel_5MW"])
fmodel.set(turbine_type=["nrel_5MW"], reference_wind_height=reference_wind_height)
fmodel.set_operation_model("simple-derating")
assert fmodel.get_operation_model() == "simple-derating"

# Check that setting over mutliple turbine types works
fmodel.set(turbine_type=["nrel_5MW", "iea_15MW"])
fmodel.set(turbine_type=["nrel_5MW", "iea_15MW"], reference_wind_height=reference_wind_height)
fmodel.set_operation_model("simple-derating")
assert fmodel.get_operation_model() == "simple-derating"
fmodel.set_operation_model(["simple-derating", "cosine-loss"])
assert fmodel.get_operation_model() == ["simple-derating", "cosine-loss"]

# Check setting over single turbine type; then updating layout works
fmodel.set(turbine_type=["nrel_5MW"])
fmodel.set(turbine_type=["nrel_5MW"], reference_wind_height=reference_wind_height)
fmodel.set_operation_model("simple-derating")
fmodel.set(layout_x=[0, 0, 0], layout_y=[0, 1000, 2000])
assert fmodel.get_operation_model() == "simple-derating"

# Check that setting for multiple turbine types and then updating layout breaks
fmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
fmodel.set(turbine_type=["nrel_5MW"])
fmodel.set(turbine_type=["nrel_5MW"], reference_wind_height=reference_wind_height)
fmodel.set_operation_model(["simple-derating", "cosine-loss"])
assert fmodel.get_operation_model() == ["simple-derating", "cosine-loss"]
with pytest.raises(ValueError):
fmodel.set(layout_x=[0, 0, 0], layout_y=[0, 1000, 2000])

# Check one more variation
fmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
fmodel.set(turbine_type=["nrel_5MW", "iea_15MW"])
fmodel.set(turbine_type=["nrel_5MW", "iea_15MW"], reference_wind_height=reference_wind_height)
fmodel.set_operation_model("simple-derating")
fmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
with pytest.raises(ValueError):
Expand Down
15 changes: 10 additions & 5 deletions tests/uncertain_floris_model_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,15 @@ def test_get_operation_model():


def test_set_operation_model():
# Define a reference wind height for cases when there are changes to
# turbine_type

ufmodel = UncertainFlorisModel(configuration=YAML_INPUT)
ufmodel.set_operation_model("simple-derating")
assert ufmodel.get_operation_model() == "simple-derating"

reference_wind_height = ufmodel.reference_wind_height

# Check multiple turbine types works
ufmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
ufmodel.set_operation_model(["simple-derating", "cosine-loss"])
Expand All @@ -424,34 +429,34 @@ def test_set_operation_model():

# Check that setting a single turbine type, and then altering the operation model works
ufmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
ufmodel.set(turbine_type=["nrel_5MW"])
ufmodel.set(turbine_type=["nrel_5MW"], reference_wind_height=reference_wind_height)
ufmodel.set_operation_model("simple-derating")
assert ufmodel.get_operation_model() == "simple-derating"

# Check that setting over mutliple turbine types works
ufmodel.set(turbine_type=["nrel_5MW", "iea_15MW"])
ufmodel.set(turbine_type=["nrel_5MW", "iea_15MW"], reference_wind_height=reference_wind_height)
ufmodel.set_operation_model("simple-derating")
assert ufmodel.get_operation_model() == "simple-derating"
ufmodel.set_operation_model(["simple-derating", "cosine-loss"])
assert ufmodel.get_operation_model() == ["simple-derating", "cosine-loss"]

# Check setting over single turbine type; then updating layout works
ufmodel.set(turbine_type=["nrel_5MW"])
ufmodel.set(turbine_type=["nrel_5MW"], reference_wind_height=reference_wind_height)
ufmodel.set_operation_model("simple-derating")
ufmodel.set(layout_x=[0, 0, 0], layout_y=[0, 1000, 2000])
assert ufmodel.get_operation_model() == "simple-derating"

# Check that setting for multiple turbine types and then updating layout breaks
ufmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
ufmodel.set(turbine_type=["nrel_5MW"])
ufmodel.set(turbine_type=["nrel_5MW"], reference_wind_height=reference_wind_height)
ufmodel.set_operation_model(["simple-derating", "cosine-loss"])
assert ufmodel.get_operation_model() == ["simple-derating", "cosine-loss"]
with pytest.raises(ValueError):
ufmodel.set(layout_x=[0, 0, 0], layout_y=[0, 1000, 2000])

# Check one more variation
ufmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
ufmodel.set(turbine_type=["nrel_5MW", "iea_15MW"])
ufmodel.set(turbine_type=["nrel_5MW", "iea_15MW"], reference_wind_height=reference_wind_height)
ufmodel.set_operation_model("simple-derating")
ufmodel.set(layout_x=[0, 0], layout_y=[0, 1000])
with pytest.raises(ValueError):
Expand Down
Loading