cleaned a bug in add_schedules and erased all related to adjacent_buildings

This commit is contained in:
Pilar Monsalvete 2023-05-03 14:14:13 -04:00
parent bdb8bf65b7
commit f060197729
6 changed files with 43 additions and 35 deletions

View File

@ -258,6 +258,8 @@ class Idf:
_schedule.Minutes_per_Item = 60
def _add_schedules(self, usage, schedule_type, new_schedules):
if len(new_schedules) < 1:
return
schedule_from_file = False
for schedule in new_schedules:
if len(schedule.values) > 168: # Hours in one week
@ -604,24 +606,26 @@ class Idf:
outside_boundary_condition = 'Outdoors'
sun_exposure = 'SunExposed'
wind_exposure = 'WindExposed'
outside_boundary_condition_object = None
idf_surface_type = self.idf_surfaces[surface.type]
_kwargs = {'Name': f'{surface.name}',
'Surface_Type': idf_surface_type,
'Zone_Name': zone_name}
if surface.type == cte.GROUND:
outside_boundary_condition = 'Ground'
sun_exposure = 'NoSun'
wind_exposure = 'NoWind'
if surface.percentage_shared is not None and surface.percentage_shared > 0.5:
outside_boundary_condition = 'Surface'
outside_boundary_condition_object = surface.name
sun_exposure = 'NoSun'
wind_exposure = 'NoWind'
if surface.type == cte.GROUND:
outside_boundary_condition = 'Ground'
sun_exposure = 'NoSun'
wind_exposure = 'NoWind'
idf_surface_type = self.idf_surfaces[surface.type]
idf_surface = self._idf.newidfobject(self._SURFACE, Name=f'{surface.name}',
Surface_Type=idf_surface_type,
Zone_Name=zone_name,
Outside_Boundary_Condition=outside_boundary_condition,
Outside_Boundary_Condition_Object=outside_boundary_condition_object,
Sun_Exposure=sun_exposure,
Wind_Exposure=wind_exposure)
_kwargs['Outside_Boundary_Condition_Object'] = outside_boundary_condition_object
_kwargs['Outside_Boundary_Condition'] = outside_boundary_condition
_kwargs['Sun_Exposure'] = sun_exposure
_kwargs['Wind_Exposure'] = wind_exposure
idf_surface = self._idf.newidfobject(self._SURFACE, **_kwargs)
coordinates = self._matrix_to_list(surface.solid_polygon.coordinates,
self._city.lower_corner)
idf_surface.setcoords(coordinates)
@ -643,28 +647,31 @@ class Idf:
outside_boundary_condition = 'Outdoors'
sun_exposure = 'SunExposed'
wind_exposure = 'WindExposed'
outside_boundary_condition_object = ''
_kwargs = {'Name': f'{boundary.parent_surface.name}',
'Surface_Type': idf_surface_type,
'Zone_Name': zone_name}
if boundary.parent_surface.type == cte.GROUND:
outside_boundary_condition = 'Ground'
sun_exposure = 'NoSun'
wind_exposure = 'NoWind'
if boundary.parent_surface.percentage_shared is not None and boundary.parent_surface.percentage_shared >= 0.5:
outside_boundary_condition = 'Surface'
outside_boundary_condition_object = boundary.parent_surface.name
sun_exposure = 'NoSun'
wind_exposure = 'NoWind'
if boundary.parent_surface.type == cte.GROUND:
outside_boundary_condition = 'Ground'
sun_exposure = 'NoSun'
wind_exposure = 'NoWind'
_kwargs['Outside_Boundary_Condition_Object'] = outside_boundary_condition_object
_kwargs['Outside_Boundary_Condition'] = outside_boundary_condition
_kwargs['Sun_Exposure'] = sun_exposure
_kwargs['Wind_Exposure'] = wind_exposure
if boundary.parent_surface.vegetation is not None:
construction_name = f'{boundary.construction_name}_{boundary.parent_surface.vegetation.name}'
else:
construction_name = boundary.construction_name
surface = self._idf.newidfobject(self._SURFACE, Name=f'{boundary.parent_surface.name}',
Surface_Type=idf_surface_type,
Zone_Name=zone_name,
Construction_Name=construction_name,
Outside_Boundary_Condition=outside_boundary_condition,
Outside_Boundary_Condition_Object=outside_boundary_condition_object,
Sun_Exposure=sun_exposure,
Wind_Exposure=wind_exposure)
_kwargs['Construction_Name'] = construction_name
surface = self._idf.newidfobject(self._SURFACE, **_kwargs)
coordinates = self._matrix_to_list(boundary.parent_surface.solid_polygon.coordinates,
self._city.lower_corner)
surface.setcoords(coordinates)

View File

@ -63,8 +63,8 @@ class InselMonthlyEnergyBalance(Insel):
levels_of_detail = self._city.level_of_detail
if levels_of_detail.geometry is None:
raise Exception(f'Level of detail of geometry not assigned')
if levels_of_detail.geometry < 1:
raise Exception(f'Level of detail of geometry = {levels_of_detail.geometry}. Required minimum level 1')
if levels_of_detail.geometry < 0.5:
raise Exception(f'Level of detail of geometry = {levels_of_detail.geometry}. Required minimum level 0.5')
if levels_of_detail.construction is None:
raise Exception(f'Level of detail of construction not assigned')
if levels_of_detail.construction < 1:

View File

@ -17,7 +17,7 @@ class EnergyBuildingsExportsFactory:
"""
Energy Buildings exports factory class
"""
def __init__(self, export_type, city, path, target_buildings=None, adjacent_buildings=None):
def __init__(self, export_type, city, path, target_buildings=None):
self._city = city
self._export_type = '_' + export_type.lower()
class_funcs = validate_import_export_type(EnergyBuildingsExportsFactory)
@ -29,8 +29,6 @@ class EnergyBuildingsExportsFactory:
path = Path(path)
self._path = path
self._target_buildings = target_buildings
self._adjacent_buildings = adjacent_buildings
@property
def _energy_ade(self):
@ -57,7 +55,7 @@ class EnergyBuildingsExportsFactory:
# todo: create a get epw file function based on the city
weather_path = (Path(__file__).parent / '../data/weather/epw/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve()
return Idf(self._city, self._path, (idf_data_path / 'Minimal.idf'), (idf_data_path / 'Energy+.idd'), weather_path,
target_buildings=self._target_buildings, adjacent_buildings=self._adjacent_buildings)
target_buildings=self._target_buildings)
@property
def _insel_monthly_energy_balance(self):

View File

@ -60,7 +60,7 @@ class CityLayerTest(TestCase):
def _genidf(self, bldgs_group):
buildings_df, target_buildings, adjacent_buildings = self._prepare_buildings(bldgs_group)
#output_path = (Path(__file__).parent / 'tests_outputs').resolve()
output_path = (Path(__file__).parent / 'tests_outputs').resolve()
city = GeometryFactory('gpandas', data_frame=buildings_df).city
ConstructionFactory('nrel', city).enrich()
UsageFactory('comnet', city).enrich()

View File

@ -13,6 +13,7 @@ from hub.imports.geometry_factory import GeometryFactory
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.usage_factory import UsageFactory
from hub.imports.weather_factory import WeatherFactory
from hub.exports.exports_factory import ExportsFactory
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
import hub.helpers.constants as cte
@ -89,7 +90,6 @@ class TestExports(TestCase):
"""
self._export_building_energy('energy_ade')
def test_sra_export(self):
"""
export to SRA
@ -110,6 +110,7 @@ class TestExports(TestCase):
ConstructionFactory('nrcan', city).enrich()
EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
UsageFactory('nrcan', city).enrich()
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
try:
EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
except Exception:

View File

@ -11,6 +11,7 @@ from unittest import TestCase
from hub.imports.geometry_factory import GeometryFactory
from hub.imports.usage_factory import UsageFactory
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.weather_factory import WeatherFactory
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
from hub.city_model_structure.greenery.vegetation import Vegetation
from hub.city_model_structure.greenery.soil import Soil
@ -32,6 +33,7 @@ class GreeneryInIdf(TestCase):
building.year_of_construction = 2006
ConstructionFactory('nrel', city).enrich()
UsageFactory('comnet', city).enrich()
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
vegetation_name = 'BaseEco'
soil_thickness = 0.18
soil_name = 'EcoRoofSoil'
@ -85,6 +87,7 @@ class GreeneryInIdf(TestCase):
building.year_of_construction = 2006
ConstructionFactory('nrel', city).enrich()
UsageFactory('comnet', city).enrich()
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
_idf = EnergyBuildingsExportsFactory('idf', city, output_path).export()
_idf.run()
with open((output_path / f'{city.name}_out.csv').resolve()) as f:
@ -98,4 +101,3 @@ class GreeneryInIdf(TestCase):
print('Without greenery')
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')