Skip to content

Commit

Permalink
Feature/power tracking update (NREL#118)
Browse files Browse the repository at this point in the history
* Example code.

* Handling for heterogeneous inflows.

* Minor documentation updates.

* Add tests for heterogeneous inflow feature.

* Add exclusion for input data file to gitignore and add file to repo.

* Another needed input excluded in gitignore...

* Updating with better tracking of individual power value and adding a total plant power value

* Minor formatting updates.

* Update `farm_power` to `wind_farm_power` to be explicit.

---------

Co-authored-by: misi9170 <[email protected]>
Co-authored-by: genevievestarke <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent 7f9ee89 commit e910d4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions hercules/emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ def run(self):
# Send inputs (initiates the AMRWind step)
self.send_data_to_amrwind()

# Log the current state
self.log_main_dict()

# Update time to next time step (TODO: check logging for pysims?)
self.sync_time_helics(self.absolute_helics_time + self.deltat)

# Receive outputs back (for next time step)
self.receive_amrwind_data()


# Log the current state
self.log_main_dict()

# If this is first iteration print the input dict
# And turn off the first iteration flag
if self.first_iteration:
Expand Down Expand Up @@ -234,10 +234,11 @@ def receive_amrwind_data(self):
turbine_wd_array = subscription_value[3 + self.num_turbines :]
self.wind_speed = wind_speed_amr_wind
self.wind_direction = wind_direction_amr_wind
wind_farm_power = sum(turbine_power_array)

# Assign Py_sim outputs
if self.main_dict["py_sims"]:
self.main_dict["py_sims"]["inputs"]["available_power"] = sum(turbine_power_array)
self.main_dict["py_sims"]["inputs"]["available_power"] += wind_farm_power
# print("sim_time_s_amr_wind = ", sim_time_s_amr_wind)
self.main_dict["py_sims"]["inputs"]["sim_time_s"] = sim_time_s_amr_wind
# print('self.main_dict[''py_sims''][''inputs''][''sim_time_s''] = ',
Expand Down Expand Up @@ -277,6 +278,7 @@ def receive_amrwind_data(self):
# Store turbine powers back to the dict
# TODO hard-coded for now assuming only one AMR-WIND
self.amr_wind_dict[self.amr_wind_names[0]]["turbine_powers"] = turbine_power_array
self.amr_wind_dict[self.amr_wind_names[0]]["wind_farm_power"] = wind_farm_power
self.amr_wind_dict[self.amr_wind_names[0]]["turbine_wind_directions"] = turbine_wd_array
self.turbine_power_array = turbine_power_array
self.amr_wind_dict[self.amr_wind_names[0]]["sim_time_s_amr_wind"] = sim_time_s_amr_wind
Expand All @@ -293,6 +295,9 @@ def receive_amrwind_data(self):
self.main_dict["hercules_comms"]["amr_wind"][self.amr_wind_names[0]][
"wind_speed"
] = wind_speed_amr_wind
self.main_dict["hercules_comms"]["amr_wind"][self.amr_wind_names[0]][
"wind_farm_power"
] = wind_farm_power

return None

Expand Down
5 changes: 5 additions & 0 deletions hercules/py_sims.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def get_py_sim_dict(self):

def step(self, main_dict):
# Collect the py_sim objects
py_sims_available_power = 0.0
for py_sim_name in self.py_sim_names:
print(py_sim_name)

Expand All @@ -73,3 +74,7 @@ def step(self, main_dict):
self.py_sim_dict[py_sim_name]["outputs"] = self.py_sim_dict[py_sim_name]["object"].step(
main_dict
)
if "Solar" in self.py_sim_dict[py_sim_name]["py_sim_type"]:
py_sims_available_power += self.py_sim_dict[py_sim_name]["outputs"]["power_mw"]*1000

self.py_sim_dict["inputs"]["available_power"] = py_sims_available_power

0 comments on commit e910d4e

Please sign in to comment.