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))]
imported_electricity = []
exported_electricity = []
self.building.self_sufficiency['hour'] = []
self.building.self_sufficiency['percent'] = []
for i in range(len(electricity_demand)):
transfer = total_hourly_pv_output[i] - electricity_demand[i]
self.building.self_sufficiency['hour'].append(transfer)
if transfer > 0:
exported_electricity.append(transfer)
imported_electricity.append(0)
else:
exported_electricity.append(0)
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 = {
'building_name': self.building.name,