Partial correction of output names and result imports
This commit is contained in:
parent
8552b7cbd1
commit
f94ce25394
|
@ -445,7 +445,7 @@ class Idf:
|
||||||
subcategory = f'ELECTRIC EQUIPMENT#{zone_name}#InteriorEquipment'
|
subcategory = f'ELECTRIC EQUIPMENT#{zone_name}#InteriorEquipment'
|
||||||
self._idf.newidfobject(self._APPLIANCES,
|
self._idf.newidfobject(self._APPLIANCES,
|
||||||
Fuel_Type=fuel_type,
|
Fuel_Type=fuel_type,
|
||||||
Name=f'{zone_name}_appliance',
|
Name=zone_name,
|
||||||
Zone_or_ZoneList_or_Space_or_SpaceList_Name=zone_name,
|
Zone_or_ZoneList_or_Space_or_SpaceList_Name=zone_name,
|
||||||
Schedule_Name=f'Appliance schedules {thermal_zone.usage_name}',
|
Schedule_Name=f'Appliance schedules {thermal_zone.usage_name}',
|
||||||
Design_Level_Calculation_Method=method,
|
Design_Level_Calculation_Method=method,
|
||||||
|
|
|
@ -11,7 +11,7 @@ class IdfAppliance(IdfBase):
|
||||||
subcategory = f'ELECTRIC EQUIPMENT#{zone_name}#InteriorEquipment'
|
subcategory = f'ELECTRIC EQUIPMENT#{zone_name}#InteriorEquipment'
|
||||||
file = self._files['appliances']
|
file = self._files['appliances']
|
||||||
self._write_to_idf_format(file, idf_cte.APPLIANCES)
|
self._write_to_idf_format(file, idf_cte.APPLIANCES)
|
||||||
self._write_to_idf_format(file, f'{zone_name}_appliance', 'Name')
|
self._write_to_idf_format(file, zone_name, 'Name')
|
||||||
self._write_to_idf_format(file, 'Electricity', 'Fuel Type')
|
self._write_to_idf_format(file, 'Electricity', 'Fuel Type')
|
||||||
self._write_to_idf_format(file, zone_name, 'Zone or ZoneList or Space or SpaceList Name')
|
self._write_to_idf_format(file, zone_name, 'Zone or ZoneList or Space or SpaceList Name')
|
||||||
self._write_to_idf_format(file, schedule_name, 'Schedule Name')
|
self._write_to_idf_format(file, schedule_name, 'Schedule Name')
|
||||||
|
|
|
@ -5,15 +5,14 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase
|
||||||
class IdfDhw(IdfBase):
|
class IdfDhw(IdfBase):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add(self, thermal_zone, zone_name):
|
def add(self, thermal_zone, zone_name):
|
||||||
name = f'DHW {zone_name}'
|
|
||||||
peak_flow_rate = thermal_zone.domestic_hot_water.peak_flow * thermal_zone.total_floor_area
|
peak_flow_rate = thermal_zone.domestic_hot_water.peak_flow * thermal_zone.total_floor_area
|
||||||
flow_rate_schedule = f'DHW_prof schedules {thermal_zone.usage_name}'
|
flow_rate_schedule = f'DHW_prof schedules {thermal_zone.usage_name}'
|
||||||
dhw_schedule = f'DHW_temp schedules {thermal_zone.usage_name}'
|
dhw_schedule = f'DHW_temp schedules {thermal_zone.usage_name}'
|
||||||
cold_temp_schedule = f'cold_temp schedules {thermal_zone.usage_name}'
|
cold_temp_schedule = f'cold_temp schedules {thermal_zone.usage_name}'
|
||||||
file = self._files['dhw']
|
file = self._files['dhw']
|
||||||
self._write_to_idf_format(file, idf_cte.DHW)
|
self._write_to_idf_format(file, idf_cte.DHW)
|
||||||
self._write_to_idf_format(file, name, 'Name')
|
self._write_to_idf_format(file, zone_name, 'Name')
|
||||||
self._write_to_idf_format(file, name, 'EndUse Subcategory')
|
self._write_to_idf_format(file, zone_name, 'EndUse Subcategory')
|
||||||
self._write_to_idf_format(file, peak_flow_rate, 'Peak Flow Rate')
|
self._write_to_idf_format(file, peak_flow_rate, 'Peak Flow Rate')
|
||||||
self._write_to_idf_format(file, flow_rate_schedule, 'Flow Rate Fraction Schedule Name')
|
self._write_to_idf_format(file, flow_rate_schedule, 'Flow Rate Fraction Schedule Name')
|
||||||
self._write_to_idf_format(file, dhw_schedule, 'Target Temperature Schedule Name')
|
self._write_to_idf_format(file, dhw_schedule, 'Target Temperature Schedule Name')
|
||||||
|
|
|
@ -1,30 +1,26 @@
|
||||||
"""
|
"""
|
||||||
Insel monthly energy balance
|
Cerc Idf result import
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Concordia CERC group
|
Copyright © 2022 Concordia CERC group
|
||||||
Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca
|
Project Coder Guille Guillermo.GutierrezMorote@concordia.ca
|
||||||
Project collaborator Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
from hub.helpers.monthly_values import MonthlyValues
|
|
||||||
import hub.helpers.constants as cte
|
|
||||||
|
|
||||||
|
|
||||||
class EnergyPlus:
|
class EnergyPlus:
|
||||||
"""
|
"""
|
||||||
Energy plus class
|
Energy plus class
|
||||||
"""
|
"""
|
||||||
def __init__(self, city, base_path):
|
def __init__(self, city, file_path):
|
||||||
self._city = city
|
self._city = city
|
||||||
self._base_path = base_path
|
with open(file_path, 'r', encoding='utf8') as csv_file:
|
||||||
|
|
||||||
@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)
|
csv_output = csv.reader(csv_file)
|
||||||
headers = next(csv_output)
|
headers = next(csv_output)
|
||||||
|
print('headers:', headers)
|
||||||
|
|
||||||
|
"""
|
||||||
building_energy_demands = {
|
building_energy_demands = {
|
||||||
'Heating (J)': [],
|
'Heating (J)': [],
|
||||||
'Cooling (J)': [],
|
'Cooling (J)': [],
|
||||||
|
@ -72,12 +68,15 @@ class EnergyPlus:
|
||||||
building_energy_demands['Lighting (J)'].append(total_lighting_demand)
|
building_energy_demands['Lighting (J)'].append(total_lighting_demand)
|
||||||
|
|
||||||
return building_energy_demands
|
return building_energy_demands
|
||||||
|
"""
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
Enrich the city by using the energy plus workflow output files (J)
|
Enrich the city by using the energy plus workflow output files (J)
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
return
|
||||||
|
"""
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
file_name = f'{building.name}_out.csv'
|
file_name = f'{building.name}_out.csv'
|
||||||
energy_plus_output_file_path = Path(self._base_path / file_name).resolve()
|
energy_plus_output_file_path = Path(self._base_path / file_name).resolve()
|
||||||
|
@ -103,3 +102,4 @@ class EnergyPlus:
|
||||||
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_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.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])]
|
building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.MONTH])]
|
||||||
|
"""
|
|
@ -22,9 +22,11 @@ class EnergyPlusMultipleBuildings:
|
||||||
|
|
||||||
with open(Path(energy_plus_output_file_path).resolve(), 'r', encoding='utf8') as csv_file:
|
with open(Path(energy_plus_output_file_path).resolve(), 'r', encoding='utf8') as csv_file:
|
||||||
csv_output = list(csv.DictReader(csv_file))
|
csv_output = list(csv.DictReader(csv_file))
|
||||||
|
print(csv_output)
|
||||||
|
return
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
building_name = building.name.upper()
|
building_name = building.name.upper()
|
||||||
|
|
||||||
buildings_energy_demands[f'Building {building_name} Heating Demand (J)'] = [
|
buildings_energy_demands[f'Building {building_name} Heating Demand (J)'] = [
|
||||||
float(
|
float(
|
||||||
row[f"{building_name} IDEAL LOADS AIR SYSTEM:Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)"])
|
row[f"{building_name} IDEAL LOADS AIR SYSTEM:Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)"])
|
||||||
|
|
|
@ -8,6 +8,7 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||||
from pathlib import Path
|
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.energy_plus import EnergyPlus
|
||||||
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
|
||||||
|
|
||||||
|
@ -60,6 +61,9 @@ class ResultFactory:
|
||||||
"""
|
"""
|
||||||
EnergyPlusMultipleBuildings(self._city, self._base_path).enrich()
|
EnergyPlusMultipleBuildings(self._city, self._base_path).enrich()
|
||||||
|
|
||||||
|
def _cerc_idf(self):
|
||||||
|
EnergyPlus(self._city, self._base_path).enrich()
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -17,6 +17,7 @@ from hub.exports.exports_factory import ExportsFactory
|
||||||
from hub.helpers.dictionaries import Dictionaries
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.imports.construction_factory import ConstructionFactory
|
from hub.imports.construction_factory import ConstructionFactory
|
||||||
from hub.imports.geometry_factory import GeometryFactory
|
from hub.imports.geometry_factory import GeometryFactory
|
||||||
|
from hub.imports.results_factory import ResultFactory
|
||||||
from hub.imports.usage_factory import UsageFactory
|
from hub.imports.usage_factory import UsageFactory
|
||||||
from hub.imports.weather_factory import WeatherFactory
|
from hub.imports.weather_factory import WeatherFactory
|
||||||
|
|
||||||
|
@ -137,19 +138,6 @@ class TestExports(TestCase):
|
||||||
year_of_construction_field='ANNEE_CONS',
|
year_of_construction_field='ANNEE_CONS',
|
||||||
function_field='CODE_UTILI',
|
function_field='CODE_UTILI',
|
||||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||||
"""=-043
|
|
||||||
"name": "01043081",
|
|
||||||
"address": "avenue de l' H\u00f4tel-de-Ville (MTL) 3751",
|
|
||||||
"function": "6911",
|
|
||||||
"height": 21,
|
|
||||||
"year_of_construction": 1964,
|
|
||||||
city = GeometryFactory('geojson',
|
|
||||||
path=file_path,
|
|
||||||
height_field='height',
|
|
||||||
year_of_construction_field='year_of_construction',
|
|
||||||
function_field='function',
|
|
||||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
|
||||||
"""
|
|
||||||
self.assertIsNotNone(city, 'city is none')
|
self.assertIsNotNone(city, 'city is none')
|
||||||
#EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
|
#EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
|
||||||
ConstructionFactory('nrcan', city).enrich()
|
ConstructionFactory('nrcan', city).enrich()
|
||||||
|
@ -159,6 +147,20 @@ class TestExports(TestCase):
|
||||||
try:
|
try:
|
||||||
idf = EnergyBuildingsExportsFactory('cerc_idf', city, self._output_path).export()
|
idf = EnergyBuildingsExportsFactory('cerc_idf', city, self._output_path).export()
|
||||||
idf.run()
|
idf.run()
|
||||||
|
csv_output_path = (self._output_path / f'{city.name}_out.csv').resolve()
|
||||||
|
ResultFactory('cerc_idf', city, csv_output_path).enrich()
|
||||||
|
self.assertTrue(csv_output_path.is_file())
|
||||||
|
"""
|
||||||
|
for building in self._city.buildings:
|
||||||
|
self.assertIsNotNone(building.heating_demand)
|
||||||
|
self.assertIsNotNone(building.cooling_demand)
|
||||||
|
self.assertIsNotNone(building.domestic_hot_water_heat_demand)
|
||||||
|
self.assertIsNotNone(building.lighting_electrical_demand)
|
||||||
|
self.assertIsNotNone(building.appliances_electrical_demand)
|
||||||
|
total_demand = sum(building.heating_demand[cte.HOUR])
|
||||||
|
self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
|
||||||
|
total_demand = sum(building.heating_demand[cte.MONTH])
|
||||||
|
self.assertEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
|
||||||
|
"""
|
||||||
except Exception:
|
except Exception:
|
||||||
self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!")
|
self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!")
|
||||||
|
|
|
@ -94,6 +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):
|
||||||
|
# todo: this tests aren't actually testing the functionality
|
||||||
ResultFactory('energy_plus_single_building', 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'
|
||||||
|
@ -117,6 +118,7 @@ class TestResultsImport(TestCase):
|
||||||
self.assertDictEqual(building.appliances_electrical_demand, {})
|
self.assertDictEqual(building.appliances_electrical_demand, {})
|
||||||
|
|
||||||
def test_energy_plus_multiple_buildings_results_import(self):
|
def test_energy_plus_multiple_buildings_results_import(self):
|
||||||
|
# todo: this tests aren't actually testing the functionality
|
||||||
ResultFactory('energy_plus_multiple_buildings', self._city, self._example_path).enrich()
|
ResultFactory('energy_plus_multiple_buildings', self._city, self._example_path).enrich()
|
||||||
csv_output_name = f'{self._city.name}_out.csv'
|
csv_output_name = f'{self._city.name}_out.csv'
|
||||||
csv_output_path = (self._example_path / csv_output_name).resolve()
|
csv_output_path = (self._example_path / csv_output_name).resolve()
|
||||||
|
@ -131,3 +133,7 @@ class TestResultsImport(TestCase):
|
||||||
self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
|
self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
|
||||||
total_demand = sum(building.heating_demand[cte.MONTH])
|
total_demand = sum(building.heating_demand[cte.MONTH])
|
||||||
self.assertEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
|
self.assertEqual(total_demand, building.heating_demand[cte.YEAR][0], 2)
|
||||||
|
|
||||||
|
def test_cerc_idf_results(self):
|
||||||
|
csv_output_path = (self._output_path / f'Montreal_out.csv').resolve()
|
||||||
|
ResultFactory('cerc_idf', self._city, csv_output_path).enrich()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user