Skip to content

Commit

Permalink
whoc battery controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary committed Dec 12, 2023
1 parent af2e7ad commit d461368
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ABL.stats_output_format = netcdf

# Whether to use helics
helics.activated = true
helics.broker_port =32000
helics.broker_port = 32000

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# ADAPTIVE MESH REFINEMENT #
Expand Down
3 changes: 2 additions & 1 deletion hercules/dummy_amr_wind.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def run(self):
turbine_powers,
turbine_wind_directions,
) = self.get_step(sim_time_s)

# ================================================================
# Communicate with control center
# Send the turbine powers for this time step and get wind speed and wind direction for the
Expand Down Expand Up @@ -246,7 +247,7 @@ def get_step(self, sim_time_s):
for turb in range(self.num_turbines)
]

turbine_wind_directions = np.zeros(self.num_turbines)
turbine_wind_directions = [0] * self.num_turbines

else:
amr_wind_speed = 8.0
Expand Down
26 changes: 16 additions & 10 deletions hercules/emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def __init__(self, controller, py_sims, input_dict):
self.main_dict["hercules_comms"]["amr_wind"][self.amr_wind_names[0]][
"wind_direction"
] = 0
self.main_dict["hercules_comms"]["amr_wind"][self.amr_wind_names[0]][
"sim_time_s_amr_wind"
] = 0

self.wind_speed = 0
self.wind_direction = 0
Expand Down Expand Up @@ -139,8 +142,10 @@ def run(self):
continue

# Update controller and py sims
self.controller.step(self.main_dict)
self.main_dict["controller"] = self.controller.get_controller_dict()
# TODO: Should 'time' in the main dict be AMR-wind time or
# helics time? Why aren't they the same?
self.main_dict["time"] = self.absolute_helics_time
self.main_dict = self.controller.step(self.main_dict)
self.py_sims.step(self.main_dict)
self.main_dict["py_sims"] = self.py_sims.get_py_sim_dict()

Expand Down Expand Up @@ -337,14 +342,15 @@ def process_periodic_publication(self):
# Periodically publish data to the surrogate

# Hard coded to single wind farm for the moment
# if "turbine_yaw_angles" in self.main_dict["hercules_comms"]\
# ["amr_wind"]\
# [self.amr_wind_names[0]]:
yaw_angles = self.main_dict["hercules_comms"]["amr_wind"][
self.amr_wind_names[0]
]["turbine_yaw_angles"]
# else: # set yaw_angles based on self.wind_direction
# yaw_angles = [self.wind_direction]*self.num_turbines
if (
"turbine_yaw_angles"
in self.main_dict["hercules_comms"]["amr_wind"][self.amr_wind_names[0]]
):
yaw_angles = self.main_dict["hercules_comms"]["amr_wind"][
self.amr_wind_names[0]
]["turbine_yaw_angles"]
else: # set yaw_angles based on self.wind_direction
yaw_angles = [self.wind_direction] * self.num_turbines

# Send timing and yaw information to AMRWind via helics
# publish on topic: control
Expand Down
2 changes: 1 addition & 1 deletion hercules/python_simulators/simple_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def return_outputs(self):
return {"power": self.power_mw, "reject": self.P_reject, "soc": self.SOC}

def step(self, inputs):
P_signal = inputs["controller"][
P_signal = inputs["setpoints"]["battery"][
"signal"
] # power available for the battery to use for charging (should be >=0)
P_avail = inputs["py_sims"]["inputs"][
Expand Down

0 comments on commit d461368

Please sign in to comment.