diff --git a/.github/workflows/continuous-integration-workflow.yaml b/.github/workflows/continuous-integration-workflow.yaml index 88a187eb..d4abf1a1 100644 --- a/.github/workflows/continuous-integration-workflow.yaml +++ b/.github/workflows/continuous-integration-workflow.yaml @@ -10,7 +10,7 @@ jobs: fail-fast: False matrix: python-version: ["3.9", "3.10", "3.11"] - os: [ubuntu-latest] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v3 @@ -24,11 +24,10 @@ jobs: pip install -e ".[develop]" pip install git+https://github.com/NREL/electrolyzer.git pip install https://github.com/NREL/SEAS/blob/main/SEAS.tar.gz?raw=true - pip install git+https://github.com/NREL/floris.git@v4 # - uses: pre-commit/action@v3.0.0 - name: Run ruff run: | - ruff . + ruff check . # ruff format - name: Run tests and collect coverage run: | diff --git a/hercules/floris_standin.py b/hercules/floris_standin.py index 1621c3c2..98e94cf1 100644 --- a/hercules/floris_standin.py +++ b/hercules/floris_standin.py @@ -208,6 +208,26 @@ def get_step(self, sim_time_s, yaw_angles=None, power_setpoints=None): turbine_wind_directions = [amr_wind_direction] * self.num_turbines + if power_setpoints is None or yaw_angles is None: + pass # No conflict with yaw angles + elif ( + (((np.array(power_setpoints) == 1e9) + | (np.array([ps is None for ps in power_setpoints]))) + | ((np.array(yaw_angles) == -1000) | (np.array([ya is None for ya in yaw_angles])) | + (np.array(yaw_angles) == amr_wind_direction)) + ).all() + ): + pass # No conflict with yaw angles + else: + # Cannot currently handle both power setpoints and nonzero yaw angles. + # If power setpoints are provided, overwrite any yaw angles. + logger.warning(( + "Received combination of power_setpoints and nonzero yaw_angles for some turbines, " + +"which can not currently be handled by the FlorisStandin. Setting yaw_angles to " + +"None." + )) + yaw_angles = None + if yaw_angles is None or (np.array(yaw_angles) == -1000).any(): # Note: -1000 is the "no value" flag for yaw_angles (NaNs not handled well) yaw_misalignments = None # Floris will remember the previous yaw angles diff --git a/tests/floris_standin_test.py b/tests/floris_standin_test.py index a7af39c9..ce2e5547 100644 --- a/tests/floris_standin_test.py +++ b/tests/floris_standin_test.py @@ -1,7 +1,7 @@ +import logging from pathlib import Path import numpy as np -import pytest from floris import FlorisModel from hercules.amr_wind_standin import AMRWindStandin from hercules.floris_standin import ( @@ -121,7 +121,7 @@ def test_FlorisStandin_get_step_yaw_angles(): [260.0, 230.0] ) -def test_FlorisStandin_get_step_power_setpoints(): +def test_FlorisStandin_get_step_power_setpoints(caplog): floris_standin = FlorisStandin(CONFIG, AMR_INPUT, smoothing_coefficient=0.0) # Get FLORIS equivalent, match layout and turbines @@ -155,10 +155,12 @@ def test_FlorisStandin_get_step_power_setpoints(): fmodel_true_tp = fmodel_true.get_turbine_powers() / 1000 assert np.allclose(fs_tp, fmodel_true_tp.flatten().tolist()) - # Test with invalid combination of yaw angles and power setpoints - with pytest.raises(ValueError): + # Test warning raise with invalid combination of yaw angles and power setpoints + with caplog.at_level(logging.WARNING): floris_standin.get_step(5.0, yaw_angles=[230.0, 240.0], power_setpoints=[1e3, 1e3]) - + assert caplog.text != "" # Checking not empty + caplog.clear() + # Test with valid combination of yaw angles and power setpoints yaw_angles = [260.0, 240.0] power_setpoints = [None, 1e3]