From 6727ee3a35c978895baac6b5a756490dad119b18 Mon Sep 17 00:00:00 2001 From: Pilar Date: Tue, 6 Dec 2022 14:16:40 -0500 Subject: [PATCH] added electrical demand for lighting and appliances to the workflow --- monthly_energy_balance.py | 50 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/monthly_energy_balance.py b/monthly_energy_balance.py index baaacd4..38b921f 100644 --- a/monthly_energy_balance.py +++ b/monthly_energy_balance.py @@ -13,6 +13,15 @@ from helpers.monthly_values import MonthlyValues from exports.energy_building_exports_factory import EnergyBuildingsExportsFactory from insel.monthly_demand_calculation import MonthlyDemandCalculation +_DAYS_A_MONTH = {cte.MONDAY: [5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 5], + cte.TUESDAY: [5, 4, 4, 4, 5, 4, 5, 4, 4, 5, 4, 4], + cte.WEDNESDAY: [5, 4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4], + cte.THURSDAY: [4, 4, 5, 4, 5, 4, 4, 5, 4, 4, 5, 4], + cte.FRIDAY: [4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5, 4], + cte.SATURDAY: [4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5], + cte.SUNDAY: [4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5], + cte.HOLIDAY: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} + class MonthlyEnergyBalance: def __init__(self, city, path, attic_heated_case, basement_heated_case, weather_format): @@ -64,6 +73,9 @@ class MonthlyEnergyBalance: insel = MonthlyDemandCalculation(self._city, tmp_path, self._weather_format) insel.run() insel.results() + + self._dhw_demand() + self._electrical_demand() self._print_results() def _print_results(self): @@ -76,7 +88,8 @@ class MonthlyEnergyBalance: print_results = heating_results else: print_results = pd.concat([print_results, heating_results], axis='columns') - print_results = pd.concat([print_results, cooling_results], axis='columns') + print_results = pd.concat([print_results, cooling_results, building.lighting_electrical_demand, + building.appliances_electrical_demand], axis='columns') file += '\n' file += 'name: ' + building.name + '\n' file += 'year of construction: ' + str(building.year_of_construction) + '\n' @@ -91,3 +104,38 @@ class MonthlyEnergyBalance: full_path_metadata = Path(self._path / 'metadata.csv').resolve() with open(full_path_metadata, 'w') as metadata_file: metadata_file.write(file) + + def _dhw_demand(self): + for building in self._city.buildings: + domestic_hot_water_demand = 0 + + def _electrical_demand(self): + for building in self._city.buildings: + lighting_demand = [] + appliances_demand = [] + thermal_zone = building.internal_zones[0].thermal_zones[0] + area = thermal_zone.total_floor_area + + for month in range(0, 12): + total_lighting = 0 + for schedule in thermal_zone.lighting.schedules: + total_day = 0 + for value in schedule.values: + total_day += value + for day_type in schedule.day_types: + total_lighting += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density + lighting_demand.append(total_lighting * area) + + total_appliances = 0 + for schedule in thermal_zone.appliances.schedules: + total_day = 0 + for value in schedule.values: + total_day += value + for day_type in schedule.day_types: + total_appliances += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density + appliances_demand.append(total_appliances * area) + + building.lighting_electrical_demand = pd.DataFrame(lighting_demand, + columns=[f'{building.name} lighting electrical demand Wh']) + building.appliances_electrical_demand = pd.DataFrame(appliances_demand, + columns=[f'{building.name} appliances electrical demand Wh'])