Skip to content

Commit

Permalink
Tests control setpoints (and add bugfix). Also limit number of worker…
Browse files Browse the repository at this point in the history
…s for testing.
  • Loading branch information
misi9170 committed Sep 9, 2024
1 parent 47b46c0 commit e036acb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion floris/parallel_floris_model_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def run(self) -> None:
t1 = timerpc()
elif self.interface == "multiprocessing":
t0 = timerpc()
self.core.initialize_domain()
parallel_run_inputs = self._preprocessing()
t1 = timerpc()
if self.return_turbine_powers_only:
Expand Down Expand Up @@ -169,7 +170,6 @@ def _preprocessing(self):
"awc_amplitudes": self.core.farm.awc_amplitudes[wc_id_split, :],
"awc_frequencies": self.core.farm.awc_frequencies[wc_id_split, :],
}

fmodel_dict_split["flow_field"]["wind_directions"] = wind_directions
fmodel_dict_split["flow_field"]["wind_speeds"] = wind_speeds
fmodel_dict_split["flow_field"]["turbulence_intensities"] = turbulence_intensities
Expand Down
27 changes: 26 additions & 1 deletion tests/parallel_floris_model_2_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_wind_data_objects(sample_inputs_fixture):
sample_inputs_fixture.core["wake"]["model_strings"]["deflection_model"] = DEFLECTION_MODEL

fmodel = FlorisModel(sample_inputs_fixture.core)
pfmodel = ParallelFlorisModel(sample_inputs_fixture.core)
pfmodel = ParallelFlorisModel(sample_inputs_fixture.core, max_workers=2)

# Create a wind rose and set onto both models
wind_speeds = np.array([8.0, 10.0, 12.0, 8.0, 10.0, 12.0])
Expand Down Expand Up @@ -188,3 +188,28 @@ def test_wind_data_objects(sample_inputs_fixture):

assert powers_fmodel_ts.shape == powers_pfmodel_ts.shape
assert np.allclose(powers_fmodel_ts, powers_pfmodel_ts)

def test_control_setpoints(sample_inputs_fixture):
"""
Check that the ParallelFlorisModel is compatible with yaw angles.
"""

sample_inputs_fixture.core["wake"]["model_strings"]["velocity_model"] = VELOCITY_MODEL
sample_inputs_fixture.core["wake"]["model_strings"]["deflection_model"] = DEFLECTION_MODEL

fmodel = FlorisModel(sample_inputs_fixture.core)
pfmodel = ParallelFlorisModel(sample_inputs_fixture.core, max_workers=2)

# Set yaw angles
yaw_angles = np.tile(np.array([[10.0, 20.0, 30.0]]), (fmodel.n_findex,1))
fmodel.set(yaw_angles=yaw_angles)
pfmodel.set(yaw_angles=yaw_angles)

# Run; get turbine powers; compare results
fmodel.run()
powers_fmodel = fmodel.get_turbine_powers()
pfmodel.run()
powers_pfmodel = pfmodel.get_turbine_powers()

assert powers_fmodel.shape == powers_pfmodel.shape
assert np.allclose(powers_fmodel, powers_pfmodel)

0 comments on commit e036acb

Please sign in to comment.