fix: fix self_sufficiency to be a percentage of the total consumption

This commit is contained in:
Majid Rezaei 2024-12-18 09:31:30 -05:00
parent 236a518973
commit 2702a7ad45

View File

@ -164,17 +164,16 @@ class PvSystemAssessment:
total_hourly_pv_output = [rooftops_pv_output[i] + facades_pv_output[i] for i in range(len(electricity_demand))] total_hourly_pv_output = [rooftops_pv_output[i] + facades_pv_output[i] for i in range(len(electricity_demand))]
imported_electricity = [] imported_electricity = []
exported_electricity = [] exported_electricity = []
self.building.self_sufficiency['hour'] = [] self.building.self_sufficiency['percent'] = []
for i in range(len(electricity_demand)): for i in range(len(electricity_demand)):
transfer = total_hourly_pv_output[i] - electricity_demand[i] transfer = total_hourly_pv_output[i] - electricity_demand[i]
self.building.self_sufficiency['hour'].append(transfer)
if transfer > 0: if transfer > 0:
exported_electricity.append(transfer) exported_electricity.append(transfer)
imported_electricity.append(0) imported_electricity.append(0)
else: else:
exported_electricity.append(0) exported_electricity.append(0)
imported_electricity.append(abs(transfer)) imported_electricity.append(abs(transfer))
self.building.self_sufficiency['year'] = sum(self.building.self_sufficiency['hour']) self.building.self_sufficiency['percent'] = sum(total_hourly_pv_output) / sum(electricity_demand) * 100
results = { results = {
'building_name': self.building.name, 'building_name': self.building.name,