diff --git a/hercules/emulator.py b/hercules/emulator.py index f5654557..1f13e0d5 100644 --- a/hercules/emulator.py +++ b/hercules/emulator.py @@ -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: @@ -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''] = ', @@ -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 @@ -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 diff --git a/hercules/py_sims.py b/hercules/py_sims.py index 49e59823..ba41980b 100644 --- a/hercules/py_sims.py +++ b/hercules/py_sims.py @@ -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) @@ -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