chnages were made to energy_plus_workflow.py

This commit is contained in:
Saeed Ranjbar 2023-09-06 14:55:14 -04:00
parent 4ae09915b1
commit a0d2f7e5bc
2 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,93 @@
"""
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
"""
import logging
from pathlib import Path
import csv
import hub.helpers.constants as cte
class EnergyPlusWorkflow:
def __init__(self, base_path):
self._base_path = base_path
@staticmethod
def _energy_plus_output_file(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)
return csv_output
@staticmethod
def _headers(csv_file):
headers = next(csv_file)
return headers
@staticmethod
def _heating_columns(headers_list):
heating_column_index = []
for index, header in enumerate(headers_list):
if "Total Heating" in header:
heating_column_index.append(index)
return heating_column_index
@staticmethod
def _cooling_columns(headers_list):
cooling_column_index = []
for index, header in enumerate(headers_list):
if "Total Cooling" in header:
cooling_column_index.append(index)
return cooling_column_index
@staticmethod
def _dhw_columns(headers_list):
dhw_column_index = []
for index, header in enumerate(headers_list):
if "DHW" in header:
dhw_column_index.append(index)
return dhw_column_index
@staticmethod
def _appliance_columns(headers_list):
appliance_column_index = []
for index, header in enumerate(headers_list):
if "InteriorEquipment" in header:
appliance_column_index.append(index)
return appliance_column_index
@staticmethod
def _lighting_columns(headers_list):
lighting_column_index = []
for index, header in enumerate(headers_list):
if "InteriorLights" in header:
lighting_column_index.append(index)
return lighting_column_index
def _heating_loads(self, csv_file_path):
csv_file = self._energy_plus_output_file(csv_file_path)
headers = self._headers(csv_file)
heating_columns_index = self._heating_columns(headers)
building_heating_demand = []
for line in csv_file:
total_heating_demand = 0
for index in heating_columns_index:
total_heating_demand += float(line[index])
building_heating_demand.append(total_heating_demand)
return building_heating_demand
def _cooling_loads(self, csv_file_path):
csv_file = self._energy_plus_output_file(csv_file_path)
headers = self._headers(csv_file)
cooling_columns_index = self._heating_columns(headers)
building_cooling_demand = []
for line in csv_file:
total_cooling_demand = 0
for index in cooling_columns_index:
total_cooling_demand += float(line[index])
building_cooling_demand.append(total_cooling_demand)
return building_cooling_demand

View File

@ -10,7 +10,7 @@ from pathlib import Path
from hub.helpers.utils import validate_import_export_type 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_workflow import EnergyPlusWorkflow
class ResultFactory: class ResultFactory:
""" """
@ -46,6 +46,13 @@ class ResultFactory:
""" """
InselMonthlyEnergyBalance(self._city, self._base_path).enrich() InselMonthlyEnergyBalance(self._city, self._base_path).enrich()
def _energy_plus_workflow(self):
"""
Enrich the city with energy plus results
"""
EnergyPlusWorkflow
def enrich(self): def enrich(self):
""" """
Enrich the city given to the class using the usage factory given handler Enrich the city given to the class using the usage factory given handler