Add .gitignore to exclude Python bytecode files
This commit is contained in:
commit
e3f1d52a21
@ -558,6 +558,7 @@ class Idf:
|
|||||||
self._add_lighting(thermal_zone, building.name)
|
self._add_lighting(thermal_zone, building.name)
|
||||||
self._add_appliances(thermal_zone, building.name)
|
self._add_appliances(thermal_zone, building.name)
|
||||||
self._add_dhw(thermal_zone, building.name)
|
self._add_dhw(thermal_zone, building.name)
|
||||||
|
# todo: @Guille: if export_type is not surfaces, we don't differentiate between shadows and buildings?
|
||||||
if self._export_type == "Surfaces":
|
if self._export_type == "Surfaces":
|
||||||
if building.name in self._target_buildings or building.name in self._adjacent_buildings:
|
if building.name in self._target_buildings or building.name in self._adjacent_buildings:
|
||||||
if building.thermal_zones_from_internal_zones is not None:
|
if building.thermal_zones_from_internal_zones is not None:
|
||||||
|
100
hub/imports/results/energy_plus_single_building.py
Normal file
100
hub/imports/results/energy_plus_single_building.py
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
"""
|
||||||
|
Insel monthly energy balance
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2022 Concordia CERC group
|
||||||
|
Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca
|
||||||
|
Project collaborator Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
from pathlib import Path
|
||||||
|
from hub.helpers.monthly_values import MonthlyValues
|
||||||
|
import csv
|
||||||
|
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
|
class EnergyPlusSingleBuilding:
|
||||||
|
def __init__(self, city, base_path):
|
||||||
|
self._city = city
|
||||||
|
self._base_path = base_path
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _building_energy_demands(energy_plus_output_file_path):
|
||||||
|
with open(Path(energy_plus_output_file_path).resolve(), 'r', encoding='utf8') as csv_file:
|
||||||
|
csv_output = csv.reader(csv_file)
|
||||||
|
headers = next(csv_output)
|
||||||
|
building_energy_demands = {
|
||||||
|
'Heating (J)': [],
|
||||||
|
'Cooling (J)': [],
|
||||||
|
'DHW (J)': [],
|
||||||
|
'Appliances (J)': [],
|
||||||
|
'Lighting (J)': []
|
||||||
|
}
|
||||||
|
heating_column_index = []
|
||||||
|
cooling_column_index = []
|
||||||
|
dhw_column_index = []
|
||||||
|
appliance_column_index = []
|
||||||
|
lighting_column_index = []
|
||||||
|
for index, header in enumerate(headers):
|
||||||
|
if "Total Heating" in header:
|
||||||
|
heating_column_index.append(index)
|
||||||
|
elif "Total Cooling" in header:
|
||||||
|
cooling_column_index.append(index)
|
||||||
|
elif "DHW" in header:
|
||||||
|
dhw_column_index.append(index)
|
||||||
|
elif "InteriorEquipment" in header:
|
||||||
|
appliance_column_index.append(index)
|
||||||
|
elif "InteriorLights" in header:
|
||||||
|
lighting_column_index.append(index)
|
||||||
|
|
||||||
|
for line in csv_output:
|
||||||
|
total_heating_demand = 0
|
||||||
|
total_cooling_demand = 0
|
||||||
|
total_dhw_demand = 0
|
||||||
|
total_appliance_demand = 0
|
||||||
|
total_lighting_demand = 0
|
||||||
|
for heating_index in heating_column_index:
|
||||||
|
total_heating_demand += float(line[heating_index])
|
||||||
|
building_energy_demands['Heating (J)'].append(total_heating_demand)
|
||||||
|
for cooling_index in cooling_column_index:
|
||||||
|
total_cooling_demand += float(line[cooling_index])
|
||||||
|
building_energy_demands['Cooling (J)'].append(total_cooling_demand)
|
||||||
|
for dhw_index in dhw_column_index:
|
||||||
|
total_dhw_demand += float(line[dhw_index]) * cte.WATTS_HOUR_TO_JULES
|
||||||
|
building_energy_demands['DHW (J)'].append(total_dhw_demand)
|
||||||
|
for appliance_index in appliance_column_index:
|
||||||
|
total_appliance_demand += float(line[appliance_index])
|
||||||
|
building_energy_demands['Appliances (J)'].append(total_appliance_demand)
|
||||||
|
for lighting_index in lighting_column_index:
|
||||||
|
total_lighting_demand += float(line[lighting_index])
|
||||||
|
building_energy_demands['Lighting (J)'].append(total_lighting_demand)
|
||||||
|
|
||||||
|
return building_energy_demands
|
||||||
|
|
||||||
|
def enrich(self):
|
||||||
|
"""
|
||||||
|
Enrich the city by using the energy plus workflow output files (J)
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
for building in self._city.buildings:
|
||||||
|
file_name = f'{building.name}_out.csv'
|
||||||
|
energy_plus_output_file_path = Path(self._base_path / file_name).resolve()
|
||||||
|
if energy_plus_output_file_path.is_file():
|
||||||
|
building_energy_demands = self._building_energy_demands(energy_plus_output_file_path)
|
||||||
|
building.heating_demand[cte.HOUR] = building_energy_demands['Heating (J)']
|
||||||
|
building.cooling_demand[cte.HOUR] = building_energy_demands['Cooling (J)']
|
||||||
|
building.domestic_hot_water_heat_demand[cte.HOUR] = building_energy_demands['DHW (J)']
|
||||||
|
building.appliances_electrical_demand[cte.HOUR] = building_energy_demands['Appliances (J)']
|
||||||
|
building.lighting_electrical_demand[cte.HOUR] = building_energy_demands['Lighting (J)']
|
||||||
|
building.heating_demand[cte.MONTH] = MonthlyValues.get_total_month(building.heating_demand[cte.HOUR])
|
||||||
|
building.cooling_demand[cte.MONTH] = MonthlyValues.get_total_month(building.cooling_demand[cte.HOUR])
|
||||||
|
building.domestic_hot_water_heat_demand[cte.MONTH] = (
|
||||||
|
MonthlyValues.get_total_month(building.domestic_hot_water_heat_demand[cte.HOUR]))
|
||||||
|
building.appliances_electrical_demand[cte.MONTH] = (
|
||||||
|
MonthlyValues.get_total_month(building.appliances_electrical_demand[cte.HOUR]))
|
||||||
|
building.lighting_electrical_demand[cte.MONTH] = (
|
||||||
|
MonthlyValues.get_total_month(building.lighting_electrical_demand[cte.HOUR]))
|
||||||
|
building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.MONTH])]
|
||||||
|
building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.MONTH])]
|
||||||
|
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.MONTH])]
|
||||||
|
building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.MONTH])]
|
||||||
|
building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.MONTH])]
|
100
hub/imports/results/ep_multiple_buildings.py
Normal file
100
hub/imports/results/ep_multiple_buildings.py
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
"""
|
||||||
|
Insel monthly energy balance
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2022 Concordia CERC group
|
||||||
|
Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca
|
||||||
|
Project collaborator Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
from pathlib import Path
|
||||||
|
from hub.helpers.monthly_values import MonthlyValues
|
||||||
|
import csv
|
||||||
|
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
|
class EnergyPlusSingleBuilding:
|
||||||
|
def __init__(self, city, base_path):
|
||||||
|
self._city = city
|
||||||
|
self._base_path = base_path
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _building_energy_demands(energy_plus_output_file_path):
|
||||||
|
with open(Path(energy_plus_output_file_path).resolve(), 'r', encoding='utf8') as csv_file:
|
||||||
|
csv_output = csv.reader(csv_file)
|
||||||
|
headers = next(csv_output)
|
||||||
|
building_energy_demands = {
|
||||||
|
'Heating (J)': [],
|
||||||
|
'Cooling (J)': [],
|
||||||
|
'DHW (J)': [],
|
||||||
|
'Appliances (J)': [],
|
||||||
|
'Lighting (J)': []
|
||||||
|
}
|
||||||
|
heating_column_index = []
|
||||||
|
cooling_column_index = []
|
||||||
|
dhw_column_index = []
|
||||||
|
appliance_column_index = []
|
||||||
|
lighting_column_index = []
|
||||||
|
for index, header in enumerate(headers):
|
||||||
|
if "Total Heating" in header:
|
||||||
|
heating_column_index.append(index)
|
||||||
|
elif "Total Cooling" in header:
|
||||||
|
cooling_column_index.append(index)
|
||||||
|
elif "DHW" in header:
|
||||||
|
dhw_column_index.append(index)
|
||||||
|
elif "InteriorEquipment" in header:
|
||||||
|
appliance_column_index.append(index)
|
||||||
|
elif "InteriorLights" in header:
|
||||||
|
lighting_column_index.append(index)
|
||||||
|
|
||||||
|
for line in csv_output:
|
||||||
|
total_heating_demand = 0
|
||||||
|
total_cooling_demand = 0
|
||||||
|
total_dhw_demand = 0
|
||||||
|
total_appliance_demand = 0
|
||||||
|
total_lighting_demand = 0
|
||||||
|
for heating_index in heating_column_index:
|
||||||
|
total_heating_demand += float(line[heating_index])
|
||||||
|
building_energy_demands['Heating (J)'].append(total_heating_demand)
|
||||||
|
for cooling_index in cooling_column_index:
|
||||||
|
total_cooling_demand += float(line[cooling_index])
|
||||||
|
building_energy_demands['Cooling (J)'].append(total_cooling_demand)
|
||||||
|
for dhw_index in dhw_column_index:
|
||||||
|
total_dhw_demand += float(line[dhw_index]) * cte.WATTS_HOUR_TO_JULES
|
||||||
|
building_energy_demands['DHW (J)'].append(total_dhw_demand)
|
||||||
|
for appliance_index in appliance_column_index:
|
||||||
|
total_appliance_demand += float(line[appliance_index])
|
||||||
|
building_energy_demands['Appliances (J)'].append(total_appliance_demand)
|
||||||
|
for lighting_index in lighting_column_index:
|
||||||
|
total_lighting_demand += float(line[lighting_index])
|
||||||
|
building_energy_demands['Lighting (J)'].append(total_lighting_demand)
|
||||||
|
|
||||||
|
return building_energy_demands
|
||||||
|
|
||||||
|
def enrich(self):
|
||||||
|
"""
|
||||||
|
Enrich the city by using the energy plus workflow output files (J)
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
for building in self._city.buildings:
|
||||||
|
file_name = f'{building.name}_out.csv'
|
||||||
|
energy_plus_output_file_path = Path(self._base_path / file_name).resolve()
|
||||||
|
if energy_plus_output_file_path.is_file():
|
||||||
|
building_energy_demands = self._building_energy_demands(energy_plus_output_file_path)
|
||||||
|
building.heating_demand[cte.HOUR] = building_energy_demands['Heating (J)']
|
||||||
|
building.cooling_demand[cte.HOUR] = building_energy_demands['Cooling (J)']
|
||||||
|
building.domestic_hot_water_heat_demand[cte.HOUR] = building_energy_demands['DHW (J)']
|
||||||
|
building.appliances_electrical_demand[cte.HOUR] = building_energy_demands['Appliances (J)']
|
||||||
|
building.lighting_electrical_demand[cte.HOUR] = building_energy_demands['Lighting (J)']
|
||||||
|
building.heating_demand[cte.MONTH] = MonthlyValues.get_total_month(building.heating_demand[cte.HOUR])
|
||||||
|
building.cooling_demand[cte.MONTH] = MonthlyValues.get_total_month(building.cooling_demand[cte.HOUR])
|
||||||
|
building.domestic_hot_water_heat_demand[cte.MONTH] = (
|
||||||
|
MonthlyValues.get_total_month(building.domestic_hot_water_heat_demand[cte.HOUR]))
|
||||||
|
building.appliances_electrical_demand[cte.MONTH] = (
|
||||||
|
MonthlyValues.get_total_month(building.appliances_electrical_demand[cte.HOUR]))
|
||||||
|
building.lighting_electrical_demand[cte.MONTH] = (
|
||||||
|
MonthlyValues.get_total_month(building.lighting_electrical_demand[cte.HOUR]))
|
||||||
|
building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.MONTH])]
|
||||||
|
building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.MONTH])]
|
||||||
|
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.MONTH])]
|
||||||
|
building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.MONTH])]
|
||||||
|
building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.MONTH])]
|
@ -11,6 +11,8 @@ from hub.helpers.utils import validate_import_export_type
|
|||||||
from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance
|
from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance
|
||||||
from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
||||||
from hub.imports.results.energy_plus import EnergyPlus
|
from hub.imports.results.energy_plus import EnergyPlus
|
||||||
|
# from hub.imports.results.ep_multiple_buildings import EnergyPlusMultiple
|
||||||
|
from hub.imports.results.energy_plus_single_building import EnergyPlusSingleBuilding
|
||||||
|
|
||||||
class ResultFactory:
|
class ResultFactory:
|
||||||
"""
|
"""
|
||||||
@ -46,11 +48,17 @@ class ResultFactory:
|
|||||||
"""
|
"""
|
||||||
InselMonthlyEnergyBalance(self._city, self._base_path).enrich()
|
InselMonthlyEnergyBalance(self._city, self._base_path).enrich()
|
||||||
|
|
||||||
def _energy_plus_workflow(self):
|
def _energy_plus_single_building(self):
|
||||||
"""
|
"""
|
||||||
Enrich the city with energy plus results
|
Enrich the city with energy plus results
|
||||||
"""
|
"""
|
||||||
EnergyPlus(self._city, self._base_path).enrich()
|
EnergyPlusSingleBuilding(self._city, self._base_path).enrich()
|
||||||
|
|
||||||
|
# def _energy_plus_multiple(self):
|
||||||
|
# """
|
||||||
|
# Enrich the city with energy plus results
|
||||||
|
# """
|
||||||
|
# EnergyPlusMultiple(self._city, self._base_path).enrich()
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
|
@ -94,7 +94,7 @@ class TestResultsImport(TestCase):
|
|||||||
self.assertIsNotNone(building.cooling_peak_load)
|
self.assertIsNotNone(building.cooling_peak_load)
|
||||||
|
|
||||||
def test_energy_plus_results_import(self):
|
def test_energy_plus_results_import(self):
|
||||||
ResultFactory('energy_plus_workflow', self._city, self._example_path).enrich()
|
ResultFactory('energy_plus_single_building', self._city, self._example_path).enrich()
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
csv_output_name = f'{building.name}_out.csv'
|
csv_output_name = f'{building.name}_out.csv'
|
||||||
csv_output_path = (self._example_path / csv_output_name).resolve()
|
csv_output_path = (self._example_path / csv_output_name).resolve()
|
||||||
|
8761
tests/tests_data/Montreal_out.csv
Normal file
8761
tests/tests_data/Montreal_out.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user