Skip to content

Commit

Permalink
Fixed outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sericson0 committed Feb 9, 2021
1 parent 4313f4a commit d5c9db5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 34 deletions.
3 changes: 3 additions & 0 deletions reo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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']
Expand Down
24 changes: 11 additions & 13 deletions reo/nested_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
26 changes: 15 additions & 11 deletions reo/nested_to_flat_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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:
Expand Down
22 changes: 12 additions & 10 deletions reo/process_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions reo/src/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit d5c9db5

Please sign in to comment.