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

Feature/reenable flasc #35

Merged
merged 4 commits into from
Jun 2, 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
Binary file modified docs/graphics/wf-power-tracking-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pandas as pd

df = pd.read_csv("hercules_output.csv")
df = pd.read_csv("outputs/hercules_output.csv")

print(df.columns)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# What packages are required for this module to be executed?
REQUIRED = [
"numpy~=1.20",
# "flasc",
"flasc~=2.0",
# "matplotlib~=3.0",
# "pandas~=2.0",
# "dash>=2.0.0",
Expand Down
89 changes: 45 additions & 44 deletions tests/controller_library_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# See https://nrel.github.io/wind-hybrid-open-controller for documentation
import numpy as np
import pandas as pd

# import pandas as pd
from whoc.controllers import (
Expand Down Expand Up @@ -73,50 +74,50 @@ def test_controller_instantiation():
_ = WindFarmPowerTrackingController(interface=test_interface, input_dict=test_hercules_dict)


# def test_LookupBasedWakeSteeringController():
# test_interface = HerculesADInterface(test_hercules_dict)

# # No lookup table passed; simply passes through wind direction to yaw angles
# test_controller = LookupBasedWakeSteeringController(
# interface=test_interface,
# input_dict=test_hercules_dict
# )

# # Check that the controller can be stepped
# test_hercules_dict["time"] = 20
# test_hercules_dict_out = test_controller.step(hercules_dict=test_hercules_dict)
# test_angles = np.array(
# test_hercules_dict_out["hercules_comms"]["amr_wind"]["test_farm"]["turbine_yaw_angles"]
# )
# wind_directions = np.array(
# test_hercules_dict["hercules_comms"]["amr_wind"]["test_farm"]["turbine_wind_directions"]
# )
# assert np.allclose(test_angles, wind_directions)

# # Lookup table that specified 20 degree offset for T000, 10 degree offset for T001 for all
# # wind directions
# test_offsets = np.array([20.0, 10.0])
# df_opt_test = pd.DataFrame(data={
# "wind_direction":[220.0, 320.0, 220.0, 320.0],
# "wind_speed":[0.0, 0.0, 20.0, 20.0],
# "yaw_angles_opt":[test_offsets]*4,
# "turbulence_intensity":[0.06]*4
# })
# test_controller = LookupBasedWakeSteeringController(
# interface=test_interface,
# input_dict=test_hercules_dict,
# df_yaw=df_opt_test
# )

# test_hercules_dict["time"] = 20
# test_hercules_dict_out = test_controller.step(hercules_dict=test_hercules_dict)
# test_angles = np.array(
# test_hercules_dict_out["hercules_comms"]["amr_wind"]["test_farm"]["turbine_yaw_angles"]
# )
# wind_directions = np.array(
# test_hercules_dict["hercules_comms"]["amr_wind"]["test_farm"]["turbine_wind_directions"]
# )
# assert np.allclose(test_angles, wind_directions - test_offsets)
def test_LookupBasedWakeSteeringController():
test_interface = HerculesADInterface(test_hercules_dict)

# No lookup table passed; simply passes through wind direction to yaw angles
test_controller = LookupBasedWakeSteeringController(
interface=test_interface,
input_dict=test_hercules_dict
)

# Check that the controller can be stepped
test_hercules_dict["time"] = 20
test_hercules_dict_out = test_controller.step(hercules_dict=test_hercules_dict)
test_angles = np.array(
test_hercules_dict_out["hercules_comms"]["amr_wind"]["test_farm"]["turbine_yaw_angles"]
)
wind_directions = np.array(
test_hercules_dict["hercules_comms"]["amr_wind"]["test_farm"]["turbine_wind_directions"]
)
assert np.allclose(test_angles, wind_directions)

# Lookup table that specified 20 degree offset for T000, 10 degree offset for T001 for all
# wind directions
test_offsets = np.array([20.0, 10.0])
df_opt_test = pd.DataFrame(data={
"wind_direction":[220.0, 320.0, 220.0, 320.0],
"wind_speed":[0.0, 0.0, 20.0, 20.0],
"yaw_angles_opt":[test_offsets]*4,
"turbulence_intensity":[0.06]*4
})
test_controller = LookupBasedWakeSteeringController(
interface=test_interface,
input_dict=test_hercules_dict,
df_yaw=df_opt_test
)

test_hercules_dict["time"] = 20
test_hercules_dict_out = test_controller.step(hercules_dict=test_hercules_dict)
test_angles = np.array(
test_hercules_dict_out["hercules_comms"]["amr_wind"]["test_farm"]["turbine_yaw_angles"]
)
wind_directions = np.array(
test_hercules_dict["hercules_comms"]["amr_wind"]["test_farm"]["turbine_wind_directions"]
)
assert np.allclose(test_angles, wind_directions - test_offsets)


def test_WindBatteryController():
Expand Down
9 changes: 2 additions & 7 deletions whoc/controllers/lookup_based_wake_steering_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import numpy as np

#from flasc.wake_steering.lookup_table_tools import get_yaw_angles_interpolant
from flasc.utilities.lookup_table_tools import get_yaw_angles_interpolant
from whoc.controllers.controller_base import ControllerBase


Expand All @@ -32,12 +32,7 @@ def __init__(self, interface, input_dict, df_yaw=None, verbose=False):
print("No offsets received; assuming nominal aligned control.")
self.wake_steering_interpolant = None
else:
# Temporarily raise an error, until we have FLASC updated and compatible
raise NotImplementedError(
"The wake steering controller is not currently implemented due to a dependency ",
" conflict from FLASC."
)
# self.wake_steering_interpolant = get_yaw_angles_interpolant(df_yaw)
self.wake_steering_interpolant = get_yaw_angles_interpolant(df_yaw)

# Set initial conditions
yaw_IC = input_dict["controller"]["initial_conditions"]["yaw"]
Expand Down
3 changes: 2 additions & 1 deletion whoc/interfaces/hercules_actuator_disk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def get_measurements(self, hercules_dict):
turbine_powers = hercules_dict["hercules_comms"]["amr_wind"][self.wf_name]["turbine_powers"]
time = hercules_dict["time"]

if "wind_power_reference" in hercules_dict["external_signals"]:
if ("external_signals" in hercules_dict
and "wind_power_reference" in hercules_dict["external_signals"]):
wind_power_reference = hercules_dict["external_signals"]["wind_power_reference"]
else:
wind_power_reference = POWER_SETPOINT_DEFAULT
Expand Down
Loading