diff --git a/hub/exports/building_energy/cerc_idf.py b/hub/exports/building_energy/cerc_idf.py index 4f4a138e..37978944 100644 --- a/hub/exports/building_energy/cerc_idf.py +++ b/hub/exports/building_energy/cerc_idf.py @@ -28,6 +28,7 @@ from hub.exports.building_energy.idf_helper.idf_shading import IdfShading from hub.exports.building_energy.idf_helper.idf_surfaces import IdfSurfaces from hub.exports.building_energy.idf_helper.idf_thermostat import IdfThermostat from hub.exports.building_energy.idf_helper.idf_ventilation import IdfVentilation +from hub.exports.building_energy.idf_helper.idf_window import IdfWindow from hub.exports.building_energy.idf_helper.idf_windows_constructions import IdfWindowsConstructions from hub.exports.building_energy.idf_helper.idf_windows_material import IdfWindowsMaterial from hub.exports.building_energy.idf_helper.idf_zone import IdfZone @@ -47,7 +48,6 @@ class CercIdf(IdfBase): def __init__(self, city, output_path, idf_file_path, idd_file_path, epw_file_path, target_buildings=None): super().__init__(city, output_path, idf_file_path, idd_file_path, epw_file_path, target_buildings) self._add_surfaces = IdfSurfaces.add - self._add_schedule = IdfSchedule.add self._add_file_schedule = IdfFileSchedule.add self._add_idf_schedule = IdfSchedule.add self._add_construction = IdfConstruction.add @@ -64,6 +64,7 @@ class CercIdf(IdfBase): self._add_heating_system = IdfHeatingSystem.add self._add_dhw = IdfDhw.add self._add_shading = IdfShading.add + self._add_windows = IdfWindow.add with open(self._idf_file_path, 'r') as base_idf: lines = base_idf.readlines() @@ -72,9 +73,6 @@ class CercIdf(IdfBase): self._idf_file.writelines(lines) self._export() - # Create base values - self._create_geometry_rules() - def _create_geometry_rules(self): file = self._files['zones'] self._write_to_idf_format(file, idf_cte.GLOBAL_GEOMETRY_RULES) @@ -179,43 +177,49 @@ class CercIdf(IdfBase): occ.sensible_radiative_internal_gain + occ.latent_internal_gain ) / occ.occupancy_density - self._add_idf_schedule(usage, 'Infiltration', self._create_infiltration_schedules(thermal_zone)) - self._add_idf_schedule(usage, 'Ventilation', self._create_ventilation_schedules(thermal_zone)) - self._add_idf_schedule(usage, 'Occupancy', thermal_zone.occupancy.occupancy_schedules) - self._add_idf_schedule(usage, 'HVAC AVAIL', thermal_zone.thermal_control.hvac_availability_schedules) - self._add_idf_schedule(usage, 'Heating thermostat', + self._add_idf_schedule(self, usage, 'Infiltration', self._create_infiltration_schedules(thermal_zone)) + self._add_idf_schedule(self, usage, 'Ventilation', self._create_ventilation_schedules(thermal_zone)) + self._add_idf_schedule(self, usage, 'Occupancy', thermal_zone.occupancy.occupancy_schedules) + self._add_idf_schedule(self, usage, 'HVAC AVAIL', thermal_zone.thermal_control.hvac_availability_schedules) + self._add_idf_schedule(self, usage, 'Heating thermostat', thermal_zone.thermal_control.heating_set_point_schedules) - self._add_idf_schedule(usage, 'Cooling thermostat', + self._add_idf_schedule(self, usage, 'Cooling thermostat', thermal_zone.thermal_control.cooling_set_point_schedules) - self._add_idf_schedule(usage, 'Lighting', thermal_zone.lighting.schedules) - self._add_idf_schedule(usage, 'Appliance', thermal_zone.appliances.schedules) - self._add_idf_schedule(usage, 'DHW_prof', thermal_zone.domestic_hot_water.schedules) - self._add_idf_schedule(usage, 'DHW_temp', self._create_constant_value_schedules(service_temperature, 24)) - self._add_idf_schedule(usage, 'Activity Level', self._create_constant_value_schedules(total_heat, 24)) - self._add_file_schedule(usage, 'cold_temp', + self._add_idf_schedule(self, usage, 'Lighting', thermal_zone.lighting.schedules) + self._add_idf_schedule(self, usage, 'Appliance', thermal_zone.appliances.schedules) + self._add_idf_schedule(self, usage, 'DHW_prof', thermal_zone.domestic_hot_water.schedules) + self._add_idf_schedule(self, usage, 'DHW_temp', + self._create_constant_value_schedules(service_temperature, 24)) + self._add_idf_schedule(self, usage, 'Activity Level', self._create_constant_value_schedules(total_heat, 24)) + self._add_file_schedule(self, usage, 'cold_temp', self._create_constant_value_schedules(building.cold_water_temperature[cte.HOUR], 24)) for thermal_boundary in thermal_zone.thermal_boundaries: - self._add_material(thermal_boundary) - self._add_construction(thermal_boundary) + self._add_material(self, thermal_boundary) + self._add_construction(self, thermal_boundary) for thermal_opening in thermal_boundary.thermal_openings: - self._add_windows_material(thermal_opening) - self._add_windows_constructions() - self._add_zone(thermal_zone, building.name) - self._add_occupancy(thermal_zone, building.name) - self._add_lighting(thermal_zone, building.name) - self._add_appliance(thermal_zone, building.name) - self._add_infiltration(thermal_zone, building.name) - self._add_ventilation(thermal_zone, building.name) - self._add_thermostat(thermal_zone) - self._add_heating_system(thermal_zone, building.name) - self._add_dhw(thermal_zone, building.name) + self._add_windows_material(self, thermal_opening) + self._add_windows_constructions(self) + self._add_zone(self, thermal_zone, building.name) + self._add_occupancy(self, thermal_zone, building.name) + self._add_lighting(self, thermal_zone, building.name) + self._add_appliance(self, thermal_zone, building.name) + self._add_infiltration(self, thermal_zone, building.name) + self._add_ventilation(self, thermal_zone, building.name) + self._add_thermostat(self, thermal_zone) + self._add_heating_system(self, thermal_zone, building.name) + self._add_dhw(self, thermal_zone, building.name) if is_target: - self._add_surfaces(building, building.name) + self._add_surfaces(self, building, building.name) + self._add_windows(self, building, building.name) else: - self._add_shading(building) + self._add_shading(self, building) self._create_output_control_lighting() # Add lighting control to the lighting + + # Create base values + self._create_geometry_rules() + # Merge files self._merge_files() self._add_outputs() diff --git a/hub/exports/building_energy/idf_helper/__init__.py b/hub/exports/building_energy/idf_helper/__init__.py index 4c7f4887..fed4f458 100644 --- a/hub/exports/building_energy/idf_helper/__init__.py +++ b/hub/exports/building_energy/idf_helper/__init__.py @@ -31,7 +31,7 @@ NON_SUN_EXPOSED = 'NoSun' NON_WIND_EXPOSED = 'NoWind' EMPTY = '' -idf_surfaces = { +idf_surfaces_dictionary = { cte.WALL: 'wall', cte.GROUND: 'floor', cte.ROOF: 'roof' diff --git a/hub/exports/building_energy/idf_helper/idf_appliance.py b/hub/exports/building_energy/idf_helper/idf_appliance.py index 6651ec58..dec3921c 100644 --- a/hub/exports/building_energy/idf_helper/idf_appliance.py +++ b/hub/exports/building_energy/idf_helper/idf_appliance.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfAppliance(IdfBase): + @staticmethod def add(self, thermal_zone, zone_name): schedule_name = f'Appliance schedules {thermal_zone.usage_name}' storeys_number = int(thermal_zone.total_floor_area / thermal_zone.footprint_area) diff --git a/hub/exports/building_energy/idf_helper/idf_construction.py b/hub/exports/building_energy/idf_helper/idf_construction.py index 244241fe..a01bfaf9 100644 --- a/hub/exports/building_energy/idf_helper/idf_construction.py +++ b/hub/exports/building_energy/idf_helper/idf_construction.py @@ -4,6 +4,8 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfConstruction(IdfBase): + + @staticmethod def _add_solid_material(self, layer): file = self._files['solid_materials'] self._write_to_idf_format(file, idf_cte.SOLID_MATERIAL) @@ -17,6 +19,7 @@ class IdfConstruction(IdfBase): self._write_to_idf_format(file, layer.solar_absorptance, 'Solar Absorptance') self._write_to_idf_format(file, layer.visible_absorptance, 'Visible Absorptance', ';') + @staticmethod def _add_default_material(self): layer = Layer() layer.material_name = 'DefaultMaterial' @@ -27,12 +30,13 @@ class IdfConstruction(IdfBase): layer.thermal_absorptance = 0.9 layer.solar_absorptance = 0.9 layer.visible_absorptance = 0.7 - self._add_solid_material(layer) + IdfConstruction._add_solid_material(self, layer) return layer + @staticmethod def add(self, thermal_boundary): if thermal_boundary.layers is None: - thermal_boundary.layers = [self._add_default_material()] + thermal_boundary.layers = [IdfConstruction._add_default_material(self)] name = f'{thermal_boundary.construction_name} {thermal_boundary.parent_surface.type}' if name not in self._constructions_added_to_idf: diff --git a/hub/exports/building_energy/idf_helper/idf_dhw.py b/hub/exports/building_energy/idf_helper/idf_dhw.py index d5124e93..0161116f 100644 --- a/hub/exports/building_energy/idf_helper/idf_dhw.py +++ b/hub/exports/building_energy/idf_helper/idf_dhw.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfDhw(IdfBase): + @staticmethod 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 diff --git a/hub/exports/building_energy/idf_helper/idf_file_schedule.py b/hub/exports/building_energy/idf_helper/idf_file_schedule.py index 23880b1e..66e24329 100644 --- a/hub/exports/building_energy/idf_helper/idf_file_schedule.py +++ b/hub/exports/building_energy/idf_helper/idf_file_schedule.py @@ -5,6 +5,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfFileSchedule(IdfBase): + @staticmethod def add(self, usage, schedule_type, schedules): schedule_name = f'{schedule_type} schedules {usage}' for schedule in schedules: diff --git a/hub/exports/building_energy/idf_helper/idf_heating_system.py b/hub/exports/building_energy/idf_helper/idf_heating_system.py index 4c9dbee3..1392cb52 100644 --- a/hub/exports/building_energy/idf_helper/idf_heating_system.py +++ b/hub/exports/building_energy/idf_helper/idf_heating_system.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfHeatingSystem(IdfBase): + @staticmethod def add(self, thermal_zone, zone_name): availability_schedule = f'HVAC AVAIL SCHEDULES {thermal_zone.usage_name}' thermostat_name = f'Thermostat {thermal_zone.usage_name}' diff --git a/hub/exports/building_energy/idf_helper/idf_infiltration.py b/hub/exports/building_energy/idf_helper/idf_infiltration.py index 93d58421..2d010270 100644 --- a/hub/exports/building_energy/idf_helper/idf_infiltration.py +++ b/hub/exports/building_energy/idf_helper/idf_infiltration.py @@ -1,9 +1,10 @@ import hub.exports.building_energy.idf_helper as idf_cte +import hub.helpers.constants as cte from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfInfiltration(IdfBase): - + @staticmethod def add(self, thermal_zone, zone_name): schedule_name = f'Infiltration schedules {thermal_zone.usage_name}' infiltration = thermal_zone.infiltration_rate_system_off * cte.HOUR_TO_SECONDS diff --git a/hub/exports/building_energy/idf_helper/idf_lighting.py b/hub/exports/building_energy/idf_helper/idf_lighting.py index 2217f3e3..d5095047 100644 --- a/hub/exports/building_energy/idf_helper/idf_lighting.py +++ b/hub/exports/building_energy/idf_helper/idf_lighting.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfLighting(IdfBase): + @staticmethod def add(self, thermal_zone, zone_name): storeys_number = int(thermal_zone.total_floor_area / thermal_zone.footprint_area) watts_per_zone_floor_area = thermal_zone.lighting.density * storeys_number diff --git a/hub/exports/building_energy/idf_helper/idf_material.py b/hub/exports/building_energy/idf_helper/idf_material.py index d9d0b1c7..a908edbd 100644 --- a/hub/exports/building_energy/idf_helper/idf_material.py +++ b/hub/exports/building_energy/idf_helper/idf_material.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfMaterial(IdfBase): + @staticmethod def _add_solid_material(self, layer): file = self._files['solid_materials'] self._write_to_idf_format(file, idf_cte.SOLID_MATERIAL) @@ -16,6 +17,7 @@ class IdfMaterial(IdfBase): self._write_to_idf_format(file, layer.solar_absorptance, 'Solar Absorptance') self._write_to_idf_format(file, layer.visible_absorptance, 'Visible Absorptance', ';') + @staticmethod def _add_nomass_material(self, layer): file = self._files['nomass_materials'] self._write_to_idf_format(file, idf_cte.NOMASS_MATERIAL) @@ -26,11 +28,12 @@ class IdfMaterial(IdfBase): self._write_to_idf_format(file, 0.7, 'Solar Absorptance') self._write_to_idf_format(file, 0.7, 'Visible Absorptance', ';') + @staticmethod def add(self, thermal_boundary): for layer in thermal_boundary.layers: if layer.material_name not in self._materials_added_to_idf: self._materials_added_to_idf[layer.material_name] = True if layer.no_mass: - self._add_nomass_material(layer) + IdfMaterial._add_nomass_material(self, layer) else: - self._add_solid_material(layer) + IdfMaterial._add_solid_material(self, layer) diff --git a/hub/exports/building_energy/idf_helper/idf_occupancy.py b/hub/exports/building_energy/idf_helper/idf_occupancy.py index 1d30c508..10fc35e1 100644 --- a/hub/exports/building_energy/idf_helper/idf_occupancy.py +++ b/hub/exports/building_energy/idf_helper/idf_occupancy.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfOccupancy(IdfBase): + @staticmethod def add(self, thermal_zone, zone_name): number_of_people = thermal_zone.occupancy.occupancy_density * thermal_zone.total_floor_area fraction_radiant = 0 diff --git a/hub/exports/building_energy/idf_helper/idf_schedule.py b/hub/exports/building_energy/idf_helper/idf_schedule.py index 7f0626a1..867eba8a 100644 --- a/hub/exports/building_energy/idf_helper/idf_schedule.py +++ b/hub/exports/building_energy/idf_helper/idf_schedule.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfSchedule(IdfBase): + @staticmethod def add(self, usage, schedule_type, schedules): if len(schedules) < 1: return diff --git a/hub/exports/building_energy/idf_helper/idf_shading.py b/hub/exports/building_energy/idf_helper/idf_shading.py index fe1d9a97..5d19e65a 100644 --- a/hub/exports/building_energy/idf_helper/idf_shading.py +++ b/hub/exports/building_energy/idf_helper/idf_shading.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfShading(IdfBase): + @staticmethod def add(self, building): name = building.name file = self._files['shading'] diff --git a/hub/exports/building_energy/idf_helper/idf_surfaces.py b/hub/exports/building_energy/idf_helper/idf_surfaces.py index c9547d13..a6cd9a74 100644 --- a/hub/exports/building_energy/idf_helper/idf_surfaces.py +++ b/hub/exports/building_energy/idf_helper/idf_surfaces.py @@ -4,13 +4,14 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfSurfaces(IdfBase): + @staticmethod def add(self, building, zone_name): # Verify if create building surfaces "by hand" it's faster wwr it's missing zone_name = f'{zone_name}' file = self._files['surfaces'] for thermal_zone in building.thermal_zones_from_internal_zones: for index, boundary in enumerate(thermal_zone.thermal_boundaries): - surface_type = idf_cte.idf_surfaces[boundary.parent_surface.type] + surface_type = idf_cte.idf_surfaces_dictionary[boundary.parent_surface.type] outside_boundary_condition = idf_cte.OUTDOORS sun_exposure = idf_cte.SUN_EXPOSED wind_exposure = idf_cte.WIND_EXPOSED diff --git a/hub/exports/building_energy/idf_helper/idf_thermostat.py b/hub/exports/building_energy/idf_helper/idf_thermostat.py index c5f6271b..3c29fc3a 100644 --- a/hub/exports/building_energy/idf_helper/idf_thermostat.py +++ b/hub/exports/building_energy/idf_helper/idf_thermostat.py @@ -3,7 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfThermostat(IdfBase): - + @staticmethod def add(self, thermal_zone): thermostat_name = f'Thermostat {thermal_zone.usage_name}' heating_schedule = f'Heating thermostat schedules {thermal_zone.usage_name}' diff --git a/hub/exports/building_energy/idf_helper/idf_ventilation.py b/hub/exports/building_energy/idf_helper/idf_ventilation.py index 10053d44..11ebdbe3 100644 --- a/hub/exports/building_energy/idf_helper/idf_ventilation.py +++ b/hub/exports/building_energy/idf_helper/idf_ventilation.py @@ -4,6 +4,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfVentilation(IdfBase): + @staticmethod def add(self, thermal_zone, zone_name): schedule_name = f'Ventilation schedules {thermal_zone.usage_name}' air_change = thermal_zone.mechanical_air_change * cte.HOUR_TO_SECONDS diff --git a/hub/exports/building_energy/idf_helper/idf_window.py b/hub/exports/building_energy/idf_helper/idf_window.py new file mode 100644 index 00000000..61cb7f49 --- /dev/null +++ b/hub/exports/building_energy/idf_helper/idf_window.py @@ -0,0 +1,9 @@ +import hub.exports.building_energy.idf_helper as idf_cte +import hub.helpers.constants as cte +from hub.exports.building_energy.idf_helper.idf_base import IdfBase + + +class IdfWindow(IdfBase): + @staticmethod + def add(self, building, zone_name): + pass \ No newline at end of file diff --git a/hub/exports/building_energy/idf_helper/idf_windows_constructions.py b/hub/exports/building_energy/idf_helper/idf_windows_constructions.py index 079fd08c..44c454ef 100644 --- a/hub/exports/building_energy/idf_helper/idf_windows_constructions.py +++ b/hub/exports/building_energy/idf_helper/idf_windows_constructions.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfWindowsConstructions(IdfBase): + @staticmethod def add(self): glazing_index = self._windows_added_to_idf['glazing_index'] + 1 for i in range(1, glazing_index): diff --git a/hub/exports/building_energy/idf_helper/idf_windows_material.py b/hub/exports/building_energy/idf_helper/idf_windows_material.py index eeb7f91b..9b9c8e28 100644 --- a/hub/exports/building_energy/idf_helper/idf_windows_material.py +++ b/hub/exports/building_energy/idf_helper/idf_windows_material.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfWindowsMaterial(IdfBase): + @staticmethod def add(self, thermal_opening): name = f'{thermal_opening.overall_u_value}_{thermal_opening.g_value}' if name not in self._windows_added_to_idf: diff --git a/hub/exports/building_energy/idf_helper/idf_zone.py b/hub/exports/building_energy/idf_helper/idf_zone.py index 1db36dae..5e3cca65 100644 --- a/hub/exports/building_energy/idf_helper/idf_zone.py +++ b/hub/exports/building_energy/idf_helper/idf_zone.py @@ -3,6 +3,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfZone(IdfBase): + @staticmethod def add(self, thermal_zone, zone_name): file = self._files['zones'] self._write_to_idf_format(file, idf_cte.ZONE)