From 301e493242217233d31813f0b52cc0fa5f91512d Mon Sep 17 00:00:00 2001 From: misi9170 Date: Sun, 2 Jun 2024 10:18:25 -0600 Subject: [PATCH 01/12] Switch to zero yaw misalignments when valid power setpoints are passed to avoid FLORIS error. --- hercules/floris_standin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hercules/floris_standin.py b/hercules/floris_standin.py index 1621c3c..ec36401 100644 --- a/hercules/floris_standin.py +++ b/hercules/floris_standin.py @@ -208,6 +208,13 @@ 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 (np.array(power_setpoints) == 1e9).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. + 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 From 7e3d27801b17b4fff1a8ee4bf2c55278110339f9 Mon Sep 17 00:00:00 2001 From: misi9170 Date: Sun, 2 Jun 2024 10:39:59 -0600 Subject: [PATCH 02/12] Raise warning, update test. --- hercules/floris_standin.py | 5 +++++ tests/floris_standin_test.py | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hercules/floris_standin.py b/hercules/floris_standin.py index ec36401..28e7527 100644 --- a/hercules/floris_standin.py +++ b/hercules/floris_standin.py @@ -213,6 +213,11 @@ def get_step(self, sim_time_s, yaw_angles=None, power_setpoints=None): 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, " + +"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(): diff --git a/tests/floris_standin_test.py b/tests/floris_standin_test.py index a7af39c..59d1f09 100644 --- a/tests/floris_standin_test.py +++ b/tests/floris_standin_test.py @@ -1,5 +1,6 @@ from pathlib import Path +import logging import numpy as np import pytest from floris import FlorisModel @@ -121,7 +122,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 +156,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] From 85fa37c21f53c3b7a492408f168e0038273ca6a6 Mon Sep 17 00:00:00 2001 From: misi9170 Date: Sun, 2 Jun 2024 11:01:12 -0600 Subject: [PATCH 03/12] More complex handling to check pairwise combos of power_setpoints and yaw_angles. --- hercules/floris_standin.py | 16 ++++++++++++---- tests/floris_standin_test.py | 3 +-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hercules/floris_standin.py b/hercules/floris_standin.py index 28e7527..98e94cf 100644 --- a/hercules/floris_standin.py +++ b/hercules/floris_standin.py @@ -208,15 +208,23 @@ 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 (np.array(power_setpoints) == 1e9).all(): + 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, " - +"which can not currently be handled by the FlorisStandin. Setting " - +"yaw angles to None." + "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 diff --git a/tests/floris_standin_test.py b/tests/floris_standin_test.py index 59d1f09..ce2e554 100644 --- a/tests/floris_standin_test.py +++ b/tests/floris_standin_test.py @@ -1,8 +1,7 @@ +import logging from pathlib import Path -import logging import numpy as np -import pytest from floris import FlorisModel from hercules.amr_wind_standin import AMRWindStandin from hercules.floris_standin import ( From 35c6f4ec566fb5903186c3a59203b17c93af35ea Mon Sep 17 00:00:00 2001 From: misi9170 Date: Wed, 12 Jun 2024 17:32:08 -0600 Subject: [PATCH 04/12] Remove unneeded local floris install. --- .github/workflows/continuous-integration-workflow.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yaml b/.github/workflows/continuous-integration-workflow.yaml index 88a187e..8159a0b 100644 --- a/.github/workflows/continuous-integration-workflow.yaml +++ b/.github/workflows/continuous-integration-workflow.yaml @@ -24,7 +24,6 @@ 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: | From bf162d29b7918b67b70733c9d89edad1018bcbce Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 2 Jul 2024 15:48:39 -0600 Subject: [PATCH 05/12] Add check to ruff statement --- .github/workflows/continuous-integration-workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yaml b/.github/workflows/continuous-integration-workflow.yaml index 8159a0b..169a535 100644 --- a/.github/workflows/continuous-integration-workflow.yaml +++ b/.github/workflows/continuous-integration-workflow.yaml @@ -27,7 +27,7 @@ jobs: # - uses: pre-commit/action@v3.0.0 - name: Run ruff run: | - ruff . + ruff check . # ruff format - name: Run tests and collect coverage run: | From b46b7eb45645e18f8378fc1414fa8f707c3b836c Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 2 Jul 2024 16:38:09 -0600 Subject: [PATCH 06/12] try forcing matplotlib version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6781048..5357fc0 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ # What packages are required for this module to be executed? REQUIRED = [ "numpy~=1.20", - "matplotlib~=3.0", + "matplotlib==3.8", "pandas~=2.0", "floris~=4.0", "nrel-pysam~=4.2", From 8e894724d9c85d883b17cfbb00f72ef03dbaf0d3 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 2 Jul 2024 16:49:57 -0600 Subject: [PATCH 07/12] try 2.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5357fc0..781ec31 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ # What packages are required for this module to be executed? REQUIRED = [ "numpy~=1.20", - "matplotlib==3.8", + "matplotlib~=2.0", "pandas~=2.0", "floris~=4.0", "nrel-pysam~=4.2", From 08b28365aca378e0b848a1e76cc377a1effa2198 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 2 Jul 2024 16:51:06 -0600 Subject: [PATCH 08/12] set it back --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 781ec31..6781048 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ # What packages are required for this module to be executed? REQUIRED = [ "numpy~=1.20", - "matplotlib~=2.0", + "matplotlib~=3.0", "pandas~=2.0", "floris~=4.0", "nrel-pysam~=4.2", From 1b5e47082faec8fd4f4bd2dc7e3baef3710c892e Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 2 Jul 2024 16:56:36 -0600 Subject: [PATCH 09/12] try 3.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6781048..cdf1d01 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ # What packages are required for this module to be executed? REQUIRED = [ "numpy~=1.20", - "matplotlib~=3.0", + "matplotlib==3.6", "pandas~=2.0", "floris~=4.0", "nrel-pysam~=4.2", From f807d5c819a8fc01a88bde82c0f5533a7d3448b0 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 2 Jul 2024 17:00:24 -0600 Subject: [PATCH 10/12] Add verbosity to output --- .github/workflows/continuous-integration-workflow.yaml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yaml b/.github/workflows/continuous-integration-workflow.yaml index 169a535..0939db1 100644 --- a/.github/workflows/continuous-integration-workflow.yaml +++ b/.github/workflows/continuous-integration-workflow.yaml @@ -33,7 +33,7 @@ jobs: run: | # -rA displays the captured output for all tests after they're run # See the docs: https://doc.pytest.org/en/latest/reference/reference.html#command-line-flags - pytest -rA tests/ + pytest -vv -rA tests/ - name: Generate coverage report # Run these tests on unit tests only so that we avoid inflating our code # coverage through the regression tests diff --git a/setup.py b/setup.py index cdf1d01..6781048 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ # What packages are required for this module to be executed? REQUIRED = [ "numpy~=1.20", - "matplotlib==3.6", + "matplotlib~=3.0", "pandas~=2.0", "floris~=4.0", "nrel-pysam~=4.2", From 8040895fc5180c27ab6c80428c2489101cbc93cc Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 3 Jul 2024 09:09:36 -0600 Subject: [PATCH 11/12] Add alternative os --- .github/workflows/continuous-integration-workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yaml b/.github/workflows/continuous-integration-workflow.yaml index 0939db1..39d141e 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 From 85c1dc85c562577ddd92b165b48250aa4986e259 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 3 Jul 2024 11:39:29 -0600 Subject: [PATCH 12/12] take out verbose tests --- .github/workflows/continuous-integration-workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yaml b/.github/workflows/continuous-integration-workflow.yaml index 39d141e..d4abf1a 100644 --- a/.github/workflows/continuous-integration-workflow.yaml +++ b/.github/workflows/continuous-integration-workflow.yaml @@ -33,7 +33,7 @@ jobs: run: | # -rA displays the captured output for all tests after they're run # See the docs: https://doc.pytest.org/en/latest/reference/reference.html#command-line-flags - pytest -vv -rA tests/ + pytest -rA tests/ - name: Generate coverage report # Run these tests on unit tests only so that we avoid inflating our code # coverage through the regression tests