From d5c9db55f4fd273b62594501c262e43810b99eee Mon Sep 17 00:00:00 2001 From: Sean Date: Tue, 9 Feb 2021 18:34:10 -0500 Subject: [PATCH] Fixed outputs --- reo/models.py | 3 +++ reo/nested_outputs.py | 24 +++++++++++------------- reo/nested_to_flat_output.py | 26 +++++++++++++++----------- reo/process_results.py | 22 ++++++++++++---------- reo/src/data_manager.py | 3 +++ 5 files changed, 44 insertions(+), 34 deletions(-) diff --git a/reo/models.py b/reo/models.py index 9ac0da045..4875fb6ce 100644 --- a/reo/models.py +++ b/reo/models.py @@ -369,6 +369,7 @@ class ElectricTariffModel(models.Model): monthly_ra_value = ArrayField(models.FloatField(null=True, blank=True), null=True, blank=True) event_hours = ArrayField(models.FloatField(null=True, blank=True), null=True, blank=True) hourly_reductions = ArrayField(models.FloatField(null=True, blank=True), null=True, blank=True) + # year_one_coincident_peak_cost_us_dollars = models.FloatField(null=True, blank=True) year_one_coincident_peak_cost_bau_us_dollars = models.FloatField(null=True, blank=True) total_coincident_peak_cost_us_dollars = models.FloatField(null=True, blank=True) @@ -1195,6 +1196,8 @@ def move_outs_to_ins(site_key, resp): resp['inputs']['Scenario']['Site'][site_key][k] = None # add try/except for get fail / bad run_uuid + + #Added Resource Adequacy site_keys = ['PV', 'Storage', 'Financial', 'LoadProfile', 'LoadProfileBoilerFuel', 'LoadProfileChillerThermal', 'ElectricTariff', 'FuelTariff', 'Generator', 'Wind', 'CHP', 'Boiler', 'ElectricChiller', 'AbsorptionChiller', 'HotTES', 'ColdTES'] diff --git a/reo/nested_outputs.py b/reo/nested_outputs.py index e49f1d7a2..38f2e1e1e 100644 --- a/reo/nested_outputs.py +++ b/reo/nested_outputs.py @@ -816,39 +816,37 @@ def list_of_string(inpt): "type": "int", "description": "Total equivalent pounds of carbon dioxide emitted from BAU generator use in the first year.", "units": "lb CO2" - } - }, - "Resource_Adequacy" : { + }, "monthly_ra_reduction": { "type": "list_of_float", "decription": "Amount of RA reduction which occurs in each month where RA is called", "units": "kW by month" }, - "monthly_ra_energy" : { + "monthly_ra_energy" : { "type": "list_of_float", "description": "RA payments from participation in wholesale energy market. Does not consider whether participation occurs in a given month", "units" : "$" - }, - "monthly_ra_dr" : { + }, + "monthly_ra_dr" : { "type": "list_of_float", "description": "RA payments from providing capacity. Does not consider whether participation occurs in given month", "units" : "$" - }, - "monthly_ra_value" : { + }, + "monthly_ra_value" : { "type" : "list_of_float", "description" : "Total monthly ra value. Is zero for months where participation does not occur", "units" : "$" - }, - "event_hours" : { + }, + "event_hours" : { "type" : "list_of_int", "description" : "Each hour which is an event hour", "units" : "hour index" - }, - "hourly_reductions" : { + }, + "hourly_reductions" : { "type" : "list_of_float", "description" : "Load reduction by event hour", "units" : "kWh" - } + } }, "CHP": { diff --git a/reo/nested_to_flat_output.py b/reo/nested_to_flat_output.py index 0f97b4cc0..f80a2409b 100644 --- a/reo/nested_to_flat_output.py +++ b/reo/nested_to_flat_output.py @@ -94,7 +94,13 @@ def nested_to_flat(nested_output): 'year_one_coincident_peak_cost': nested_output['Scenario']['Site']['ElectricTariff']['year_one_coincident_peak_cost_us_dollars'], 'year_one_coincident_peak_cost_bau': nested_output['Scenario']['Site']['ElectricTariff']['year_one_coincident_peak_cost_bau_us_dollars'], 'total_coincident_peak_cost': nested_output['Scenario']['Site']['ElectricTariff']['total_coincident_peak_cost_us_dollars'], - 'total_coincident_peak_cost_bau': nested_output['Scenario']['Site']['ElectricTariff']['total_coincident_peak_cost_bau_us_dollars'] + 'total_coincident_peak_cost_bau': nested_output['Scenario']['Site']['ElectricTariff']['total_coincident_peak_cost_bau_us_dollars'], + 'monthly_ra_reduction':nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_reduction'], + 'monthly_ra_energy':nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_energy'], + 'monthly_ra_dr': nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_dr'], + 'monthly_ra_value': nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_value'], + 'event_hours': nested_output['Scenario']['Site']['ElectricTariff']['event_hours'], + 'hourly_reductions': nested_output['Scenario']['Site']['ElectricTariff']['hourly_reductions'] } if nested_output['Scenario']['Site'].get('Wind') is not None: base.update({ @@ -106,16 +112,14 @@ def nested_to_flat(nested_output): 'year_one_wind_to_grid_series': nested_output['Scenario']['Site']['Wind']['year_one_to_grid_series_kw'] }) #_______________________________________________________________________________________________________________ - #Updated for Resource Adequacy - if nested_output['Scenario']['Site'].get('Resource_Adequacy') is not None: - base.update({ - 'monthly_ra_reduction':nested_output['Scenario']['Site']['Resource_Adequacy']['monthly_ra_reduction'], - 'monthly_ra_energy':nested_output['Scenario']['Site']['Resource_Adequacy']['monthly_ra_energy'], - 'monthly_ra_dr': nested_output['Scenario']['Site']['Resource_Adequacy']['monthly_ra_dr'], - 'monthly_ra_value': nested_output['Scenario']['Site']['Resource_Adequacy']['monthly_ra_value'], - 'event_hours': nested_output['Scenario']['Site']['Resource_Adequacy']['event_hours'], - 'hourly_reductions': nested_output['Scenario']['Site']['Resource_Adequacy']['hourly_reductions'] - }) + # with open("nested output values.txt", "w") as f: + # print(f"monthly ra reductions {nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_reduction']}", file = f) + # print(f"monthly ra energy {nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_energy']}", file = f) + # print(f"monthly ra dr {nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_dr']}", file = f) + # print(f"monthly ra value {nested_output['Scenario']['Site']['ElectricTariff']['monthly_ra_value']}", file = f) + # print(f"event hours {nested_output['Scenario']['Site']['ElectricTariff']['event_hours']}", file = f) + # print(f"hourly reductions {nested_output['Scenario']['Site']['ElectricTariff']['hourly_reductions']}", file = f) + # "monthly_ra_reduction", "monthly_ra_energy","monthly_ra_dr","monthly_ra_value", "event_hours", "hourly_reductions" #________________________________________________________________________________________________________________ if nested_output['Scenario']['Site'].get('Generator') is not None: diff --git a/reo/process_results.py b/reo/process_results.py index 58bb3fe98..2ba4c9c71 100644 --- a/reo/process_results.py +++ b/reo/process_results.py @@ -540,16 +540,7 @@ def get_nested(self): data['inputs']['Scenario']["Site"]["Wind"]["federal_itc_pct"] = wind_model.federal_itc_pct else: self.nested_outputs["Scenario"]["Site"][name]['lcoe_us_dollars_per_kwh'] = None - #_________________________________________________________________________________________ - #Added Resource Adequacy Outputs - elif name == "Resource_Adequacy": - self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_reduction"] = self.results_dict.get("monthly_ra_reduction", 0) - self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_energy"] = self.results_dict.get("monthly_ra_energy") - self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_dr"] = self.results_dict.get("monthly_ra_dr") - self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_value"] = self.results_dict.get("monthly_ra_value") - self.nested_outputs["Scenario"]["Site"][name]["event_hours"] = self.results_dict.get("event_hours") - self.nested_outputs["Scenario"]["Site"][name]["hourly_reductions"] = self.results_dict.get("hourly_reductions") - #_________________________________________________________________________________________ + elif name == "Storage": self.nested_outputs["Scenario"]["Site"][name]["size_kw"] = self.results_dict.get("batt_kw", 0) self.nested_outputs["Scenario"]["Site"][name]["size_kwh"] = self.results_dict.get("batt_kwh", 0) @@ -633,6 +624,17 @@ def get_nested(self): "year_one_chp_standby_cost_us_dollars"] = self.results_dict.get("year_one_chp_standby_cost") self.nested_outputs["Scenario"]["Site"][name][ "total_chp_standby_cost_us_dollars"] = self.results_dict.get("total_chp_standby_cost") + + self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_reduction"] = self.results_dict.get("monthly_ra_reduction", 0) + self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_energy"] = self.results_dict.get("monthly_ra_energy") + self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_dr"] = self.results_dict.get("monthly_ra_dr") + self.nested_outputs["Scenario"]["Site"][name]["monthly_ra_value"] = self.results_dict.get("monthly_ra_value") + self.nested_outputs["Scenario"]["Site"][name]["event_hours"] = self.results_dict.get("event_hours") + self.nested_outputs["Scenario"]["Site"][name]["hourly_reductions"] = self.results_dict.get("hourly_reductions") + + + + elif name == "FuelTariff": self.nested_outputs["Scenario"]["Site"][name][ "total_boiler_fuel_cost_us_dollars"] = self.results_dict.get("total_boiler_fuel_cost") diff --git a/reo/src/data_manager.py b/reo/src/data_manager.py index edc58514d..1994cafb2 100644 --- a/reo/src/data_manager.py +++ b/reo/src/data_manager.py @@ -81,6 +81,9 @@ def __init__(self, run_id, user_id=None, n_timesteps=8760): self.timeout_decomp_subproblem_seconds = None self.add_soc_incentive = None + #Resource Adeqacy + self.resource_adequacy = None + # following attributes used to pass data to process_results.py # If we serialize the python classes then we could pass the objects between Celery tasks # (which we could do by making a custom serializer, but have not yet).