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] Warn users if the turbine_type is set without setting reference_wind_height #1000

Merged
merged 3 commits into from
Oct 17, 2024
Merged
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
10 changes: 10 additions & 0 deletions floris/floris_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ def _reinitialize(
if layout_y is not None:
farm_dict["layout_y"] = layout_y
if turbine_type is not None:
if reference_wind_height is None:
self.logger.warning(
"turbine_type has been changed without specifying a new "
+"reference_wind_height. reference_wind_height remains {0:.2f} m.".format(
flow_field_dict["reference_wind_height"]
)
+f" Consider calling `{self.__class__.__name__}."
+"assign_hub_height_to_ref_height` to update the reference wind height to the "
+"turbine hub height."
)
farm_dict["turbine_type"] = turbine_type
if turbine_library_path is not None:
farm_dict["turbine_library_path"] = turbine_library_path
Expand Down
26 changes: 26 additions & 0 deletions tests/floris_model_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,3 +782,29 @@ def test_set_operation():
with pytest.raises(ValueError):
fmodel.set_operation(yaw_angles=np.array([[25.0, 0.0], [25.0, 0.0]]))
fmodel.run()

def test_reference_wind_height_methods(caplog):
fmodel = FlorisModel(configuration=YAML_INPUT)

# Check that if the turbine type is changed, a warning is raised/not raised regarding the
# reference wind height
with caplog.at_level(logging.WARNING):
fmodel.set(turbine_type=["iea_15MW"])
assert caplog.text != "" # Checking not empty
caplog.clear()
with caplog.at_level(logging.WARNING):
fmodel.set(turbine_type=["iea_15MW"], reference_wind_height=100.0)
assert caplog.text == "" # Checking empty

# Check that assigning the reference wind height to the turbine hub height works
assert fmodel.core.flow_field.reference_wind_height == 100.0 # Set in line above
fmodel.assign_hub_height_to_ref_height()
assert fmodel.core.flow_field.reference_wind_height == 150.0 # 150m is HH for IEA 15MW

with pytest.raises(ValueError):
fmodel.set(
layout_x = [0.0, 0.0],
layout_y = [0.0, 1000.0],
turbine_type=["nrel_5MW", "iea_15MW"]
)
fmodel.assign_hub_height_to_ref_height() # Shouldn't allow due to multiple turbine types
Loading