78 lines
3.6 KiB
Python
78 lines
3.6 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 = 1
|
|
# elec_cooling = 1
|
|
# elec_dhw = 1
|
|
# 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]
|
|
heating = self.building.heating_demand[cte.HOUR] * 70
|
|
# 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]
|
|
dhw = self.building.domestic_hot_water_heat_demand[cte.HOUR] * 70
|
|
# 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]
|
|
cooling = self.building.cooling_demand[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)
|
|
self.building.distribution_systems_electrical_consumption = hourly_electricity_consumption
|
|
return hourly_electricity_consumption
|