Skip to content

Commit

Permalink
Add test showing missing error
Browse files Browse the repository at this point in the history
  • Loading branch information
rafmudaf committed Dec 5, 2024
1 parent cf05538 commit c5f30bc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
11 changes: 9 additions & 2 deletions floris/floris_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,9 +1745,16 @@ def reinitialize(self, **_):

@staticmethod
def merge_floris_models(fmodel_list, reference_wind_height=None):
"""Merge a list of FlorisModel objects into a single FlorisModel object. Note that it uses
the very first object specified in fmodel_list to build upon,
"""Merge a list of FlorisModel objects into a single FlorisModel object.
Note that it uses the first object specified in fmodel_list to build upon,
so it uses those wake model parameters, air density, and so on.
Currently, this function supports merging the following components of the FLORIS inputs:
- farm
- layout_x
- layout_y
- turbine_type
- flow_field
- reference_wind_height
Args:
fmodel_list (list): Array-like of FlorisModel objects.
Expand Down
27 changes: 27 additions & 0 deletions tests/floris_model_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,30 @@ def test_reference_wind_height_methods(caplog):
turbine_type=["nrel_5MW", "iea_15MW"]
)
fmodel.assign_hub_height_to_ref_height() # Shouldn't allow due to multiple turbine types

def test_merge_floris_models():

# Check that the merge function extends the data as expected
fmodel1 = FlorisModel(configuration=YAML_INPUT)
fmodel1.set(
layout_x=[0, 1000],
layout_y=[0, 0]
)
fmodel2 = FlorisModel(configuration=YAML_INPUT)
fmodel2.set(
layout_x=[2000, 3000],
layout_y=[0, 0]
)

merged_fmodel = FlorisModel.merge_floris_models([fmodel1, fmodel2])
assert merged_fmodel.n_turbines == 4

# Check that this model will run without error
merged_fmodel.run()

# Verify error handling

## Input list with incorrect types
fmodel_list = [fmodel1, "not a floris model"]
with pytest.raises(TypeError):
merged_fmodel = FlorisModel.merge_floris_models(fmodel_list)

0 comments on commit c5f30bc

Please sign in to comment.