forked from s_ranjbar/city_retrofit
cleaned a bug in add_schedules and erased all related to adjacent_buildings
This commit is contained in:
parent
bdb8bf65b7
commit
f060197729
|
@ -258,6 +258,8 @@ class Idf:
|
||||||
_schedule.Minutes_per_Item = 60
|
_schedule.Minutes_per_Item = 60
|
||||||
|
|
||||||
def _add_schedules(self, usage, schedule_type, new_schedules):
|
def _add_schedules(self, usage, schedule_type, new_schedules):
|
||||||
|
if len(new_schedules) < 1:
|
||||||
|
return
|
||||||
schedule_from_file = False
|
schedule_from_file = False
|
||||||
for schedule in new_schedules:
|
for schedule in new_schedules:
|
||||||
if len(schedule.values) > 168: # Hours in one week
|
if len(schedule.values) > 168: # Hours in one week
|
||||||
|
@ -604,24 +606,26 @@ class Idf:
|
||||||
outside_boundary_condition = 'Outdoors'
|
outside_boundary_condition = 'Outdoors'
|
||||||
sun_exposure = 'SunExposed'
|
sun_exposure = 'SunExposed'
|
||||||
wind_exposure = 'WindExposed'
|
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:
|
if surface.percentage_shared is not None and surface.percentage_shared > 0.5:
|
||||||
outside_boundary_condition = 'Surface'
|
outside_boundary_condition = 'Surface'
|
||||||
outside_boundary_condition_object = surface.name
|
outside_boundary_condition_object = surface.name
|
||||||
sun_exposure = 'NoSun'
|
sun_exposure = 'NoSun'
|
||||||
wind_exposure = 'NoWind'
|
wind_exposure = 'NoWind'
|
||||||
if surface.type == cte.GROUND:
|
_kwargs['Outside_Boundary_Condition_Object'] = outside_boundary_condition_object
|
||||||
outside_boundary_condition = 'Ground'
|
|
||||||
sun_exposure = 'NoSun'
|
_kwargs['Outside_Boundary_Condition'] = outside_boundary_condition
|
||||||
wind_exposure = 'NoWind'
|
_kwargs['Sun_Exposure'] = sun_exposure
|
||||||
idf_surface_type = self.idf_surfaces[surface.type]
|
_kwargs['Wind_Exposure'] = wind_exposure
|
||||||
idf_surface = self._idf.newidfobject(self._SURFACE, Name=f'{surface.name}',
|
idf_surface = self._idf.newidfobject(self._SURFACE, **_kwargs)
|
||||||
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)
|
|
||||||
coordinates = self._matrix_to_list(surface.solid_polygon.coordinates,
|
coordinates = self._matrix_to_list(surface.solid_polygon.coordinates,
|
||||||
self._city.lower_corner)
|
self._city.lower_corner)
|
||||||
idf_surface.setcoords(coordinates)
|
idf_surface.setcoords(coordinates)
|
||||||
|
@ -643,28 +647,31 @@ class Idf:
|
||||||
outside_boundary_condition = 'Outdoors'
|
outside_boundary_condition = 'Outdoors'
|
||||||
sun_exposure = 'SunExposed'
|
sun_exposure = 'SunExposed'
|
||||||
wind_exposure = 'WindExposed'
|
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:
|
if boundary.parent_surface.percentage_shared is not None and boundary.parent_surface.percentage_shared >= 0.5:
|
||||||
outside_boundary_condition = 'Surface'
|
outside_boundary_condition = 'Surface'
|
||||||
outside_boundary_condition_object = boundary.parent_surface.name
|
outside_boundary_condition_object = boundary.parent_surface.name
|
||||||
sun_exposure = 'NoSun'
|
sun_exposure = 'NoSun'
|
||||||
wind_exposure = 'NoWind'
|
wind_exposure = 'NoWind'
|
||||||
if boundary.parent_surface.type == cte.GROUND:
|
_kwargs['Outside_Boundary_Condition_Object'] = outside_boundary_condition_object
|
||||||
outside_boundary_condition = 'Ground'
|
_kwargs['Outside_Boundary_Condition'] = outside_boundary_condition
|
||||||
sun_exposure = 'NoSun'
|
_kwargs['Sun_Exposure'] = sun_exposure
|
||||||
wind_exposure = 'NoWind'
|
_kwargs['Wind_Exposure'] = wind_exposure
|
||||||
|
|
||||||
if boundary.parent_surface.vegetation is not None:
|
if boundary.parent_surface.vegetation is not None:
|
||||||
construction_name = f'{boundary.construction_name}_{boundary.parent_surface.vegetation.name}'
|
construction_name = f'{boundary.construction_name}_{boundary.parent_surface.vegetation.name}'
|
||||||
else:
|
else:
|
||||||
construction_name = boundary.construction_name
|
construction_name = boundary.construction_name
|
||||||
surface = self._idf.newidfobject(self._SURFACE, Name=f'{boundary.parent_surface.name}',
|
_kwargs['Construction_Name'] = construction_name
|
||||||
Surface_Type=idf_surface_type,
|
|
||||||
Zone_Name=zone_name,
|
surface = self._idf.newidfobject(self._SURFACE, **_kwargs)
|
||||||
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)
|
|
||||||
coordinates = self._matrix_to_list(boundary.parent_surface.solid_polygon.coordinates,
|
coordinates = self._matrix_to_list(boundary.parent_surface.solid_polygon.coordinates,
|
||||||
self._city.lower_corner)
|
self._city.lower_corner)
|
||||||
surface.setcoords(coordinates)
|
surface.setcoords(coordinates)
|
||||||
|
|
|
@ -63,8 +63,8 @@ class InselMonthlyEnergyBalance(Insel):
|
||||||
levels_of_detail = self._city.level_of_detail
|
levels_of_detail = self._city.level_of_detail
|
||||||
if levels_of_detail.geometry is None:
|
if levels_of_detail.geometry is None:
|
||||||
raise Exception(f'Level of detail of geometry not assigned')
|
raise Exception(f'Level of detail of geometry not assigned')
|
||||||
if levels_of_detail.geometry < 1:
|
if levels_of_detail.geometry < 0.5:
|
||||||
raise Exception(f'Level of detail of geometry = {levels_of_detail.geometry}. Required minimum level 1')
|
raise Exception(f'Level of detail of geometry = {levels_of_detail.geometry}. Required minimum level 0.5')
|
||||||
if levels_of_detail.construction is None:
|
if levels_of_detail.construction is None:
|
||||||
raise Exception(f'Level of detail of construction not assigned')
|
raise Exception(f'Level of detail of construction not assigned')
|
||||||
if levels_of_detail.construction < 1:
|
if levels_of_detail.construction < 1:
|
||||||
|
|
|
@ -17,7 +17,7 @@ class EnergyBuildingsExportsFactory:
|
||||||
"""
|
"""
|
||||||
Energy Buildings exports factory class
|
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._city = city
|
||||||
self._export_type = '_' + export_type.lower()
|
self._export_type = '_' + export_type.lower()
|
||||||
class_funcs = validate_import_export_type(EnergyBuildingsExportsFactory)
|
class_funcs = validate_import_export_type(EnergyBuildingsExportsFactory)
|
||||||
|
@ -29,8 +29,6 @@ class EnergyBuildingsExportsFactory:
|
||||||
path = Path(path)
|
path = Path(path)
|
||||||
self._path = path
|
self._path = path
|
||||||
self._target_buildings = target_buildings
|
self._target_buildings = target_buildings
|
||||||
self._adjacent_buildings = adjacent_buildings
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _energy_ade(self):
|
def _energy_ade(self):
|
||||||
|
@ -57,7 +55,7 @@ class EnergyBuildingsExportsFactory:
|
||||||
# todo: create a get epw file function based on the city
|
# 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()
|
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,
|
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
|
@property
|
||||||
def _insel_monthly_energy_balance(self):
|
def _insel_monthly_energy_balance(self):
|
||||||
|
|
|
@ -60,7 +60,7 @@ class CityLayerTest(TestCase):
|
||||||
|
|
||||||
def _genidf(self, bldgs_group):
|
def _genidf(self, bldgs_group):
|
||||||
buildings_df, target_buildings, adjacent_buildings = self._prepare_buildings(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
|
city = GeometryFactory('gpandas', data_frame=buildings_df).city
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
UsageFactory('comnet', city).enrich()
|
UsageFactory('comnet', city).enrich()
|
||||||
|
|
|
@ -13,6 +13,7 @@ from hub.imports.geometry_factory import GeometryFactory
|
||||||
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.usage_factory import UsageFactory
|
from hub.imports.usage_factory import UsageFactory
|
||||||
|
from hub.imports.weather_factory import WeatherFactory
|
||||||
from hub.exports.exports_factory import ExportsFactory
|
from hub.exports.exports_factory import ExportsFactory
|
||||||
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
@ -89,7 +90,6 @@ class TestExports(TestCase):
|
||||||
"""
|
"""
|
||||||
self._export_building_energy('energy_ade')
|
self._export_building_energy('energy_ade')
|
||||||
|
|
||||||
|
|
||||||
def test_sra_export(self):
|
def test_sra_export(self):
|
||||||
"""
|
"""
|
||||||
export to SRA
|
export to SRA
|
||||||
|
@ -110,6 +110,7 @@ class TestExports(TestCase):
|
||||||
ConstructionFactory('nrcan', city).enrich()
|
ConstructionFactory('nrcan', city).enrich()
|
||||||
EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
|
EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
|
||||||
UsageFactory('nrcan', city).enrich()
|
UsageFactory('nrcan', city).enrich()
|
||||||
|
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
|
||||||
try:
|
try:
|
||||||
EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
|
EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -11,6 +11,7 @@ from unittest import TestCase
|
||||||
from hub.imports.geometry_factory import GeometryFactory
|
from hub.imports.geometry_factory import GeometryFactory
|
||||||
from hub.imports.usage_factory import UsageFactory
|
from hub.imports.usage_factory import UsageFactory
|
||||||
from hub.imports.construction_factory import ConstructionFactory
|
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.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
||||||
from hub.city_model_structure.greenery.vegetation import Vegetation
|
from hub.city_model_structure.greenery.vegetation import Vegetation
|
||||||
from hub.city_model_structure.greenery.soil import Soil
|
from hub.city_model_structure.greenery.soil import Soil
|
||||||
|
@ -32,6 +33,7 @@ class GreeneryInIdf(TestCase):
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
UsageFactory('comnet', city).enrich()
|
UsageFactory('comnet', city).enrich()
|
||||||
|
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
|
||||||
vegetation_name = 'BaseEco'
|
vegetation_name = 'BaseEco'
|
||||||
soil_thickness = 0.18
|
soil_thickness = 0.18
|
||||||
soil_name = 'EcoRoofSoil'
|
soil_name = 'EcoRoofSoil'
|
||||||
|
@ -85,6 +87,7 @@ class GreeneryInIdf(TestCase):
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
UsageFactory('comnet', 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 = EnergyBuildingsExportsFactory('idf', city, output_path).export()
|
||||||
_idf.run()
|
_idf.run()
|
||||||
with open((output_path / f'{city.name}_out.csv').resolve()) as f:
|
with open((output_path / f'{city.name}_out.csv').resolve()) as f:
|
||||||
|
@ -98,4 +101,3 @@ class GreeneryInIdf(TestCase):
|
||||||
|
|
||||||
print('Without greenery')
|
print('Without greenery')
|
||||||
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')
|
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user