76 lines
3.3 KiB
Python
76 lines
3.3 KiB
Python
import hub.helpers.constants as cte
|
|
class HourlyElectricityDemand:
|
|
def __init__(self, building):
|
|
self.building = building
|
|
|
|
def calculate(self):
|
|
hourly_electricity_consumption = []
|
|
energy_systems = self.building.energy_systems
|
|
appliance = self.building.appliances_electrical_demand[cte.HOUR] if self.building.appliances_electrical_demand else 0
|
|
lighting = self.building.lighting_electrical_demand[cte.HOUR] if self.building.lighting_electrical_demand else 0
|
|
elec_heating = 0
|
|
elec_cooling = 0
|
|
elec_dhw = 0
|
|
if cte.HEATING in self.building.energy_consumption_breakdown[cte.ELECTRICITY]:
|
|
elec_heating = 1
|
|
if cte.COOLING in self.building.energy_consumption_breakdown[cte.ELECTRICITY]:
|
|
elec_cooling = 1
|
|
if cte.DOMESTIC_HOT_WATER in self.building.energy_consumption_breakdown[cte.ELECTRICITY]:
|
|
elec_dhw = 1
|
|
heating = None
|
|
cooling = None
|
|
dhw = None
|
|
|
|
if elec_heating == 1:
|
|
for energy_system in energy_systems:
|
|
if cte.HEATING in energy_system.demand_types:
|
|
for generation_system in energy_system.generation_systems:
|
|
if generation_system.fuel_type == cte.ELECTRICITY:
|
|
if cte.HEATING in generation_system.energy_consumption:
|
|
heating = generation_system.energy_consumption[cte.HEATING][cte.HOUR]
|
|
else:
|
|
if len(energy_system.generation_systems) > 1:
|
|
heating = [x / 2 for x in self.building.heating_consumption[cte.HOUR]]
|
|
else:
|
|
heating = self.building.heating_consumption[cte.HOUR]
|
|
|
|
if elec_dhw == 1:
|
|
for energy_system in energy_systems:
|
|
if cte.DOMESTIC_HOT_WATER in energy_system.demand_types:
|
|
for generation_system in energy_system.generation_systems:
|
|
if generation_system.fuel_type == cte.ELECTRICITY:
|
|
if cte.DOMESTIC_HOT_WATER in generation_system.energy_consumption:
|
|
dhw = generation_system.energy_consumption[cte.DOMESTIC_HOT_WATER][cte.HOUR]
|
|
else:
|
|
if len(energy_system.generation_systems) > 1:
|
|
dhw = [x / 2 for x in self.building.domestic_hot_water_consumption[cte.HOUR]]
|
|
else:
|
|
dhw = self.building.domestic_hot_water_consumption[cte.HOUR]
|
|
|
|
if elec_cooling == 1:
|
|
for energy_system in energy_systems:
|
|
if cte.COOLING in energy_system.demand_types:
|
|
for generation_system in energy_system.generation_systems:
|
|
if cte.COOLING in generation_system.energy_consumption:
|
|
cooling = generation_system.energy_consumption[cte.COOLING][cte.HOUR]
|
|
else:
|
|
if len(energy_system.generation_systems) > 1:
|
|
cooling = [x / 2 for x in self.building.cooling_consumption[cte.HOUR]]
|
|
else:
|
|
cooling = self.building.cooling_consumption[cte.HOUR]
|
|
|
|
for i in range(8760):
|
|
hourly = 0
|
|
if isinstance(appliance, list):
|
|
hourly += appliance[i]
|
|
if isinstance(lighting, list):
|
|
hourly += lighting[i]
|
|
if heating is not None:
|
|
hourly += heating[i]
|
|
if cooling is not None:
|
|
hourly += cooling[i]
|
|
if dhw is not None:
|
|
hourly += dhw[i]
|
|
hourly_electricity_consumption.append(hourly)
|
|
return hourly_electricity_consumption
|