From 14404fbf04e859a9816aa1dca547c809c0efc35f Mon Sep 17 00:00:00 2001 From: guille Date: Fri, 8 Nov 2024 06:41:15 +0100 Subject: [PATCH] Include oriol's infiltration changes into cerc_idf and remove empty file --- hub/exports/building_energy/cerc_idf.py | 6 +++++- hub/exports/building_energy/idf_files/outputs.idf | 10 ++++++++++ hub/exports/building_energy/idf_helper/idf_base.py | 4 +++- .../building_energy/idf_helper/idf_infiltration.py | 14 +++++++++++--- .../building_energy/idf_helper/idf_window.py | 14 +++++--------- hub/imports/weather/EPWCLEANER | 0 6 files changed, 34 insertions(+), 14 deletions(-) delete mode 100644 hub/imports/weather/EPWCLEANER diff --git a/hub/exports/building_energy/cerc_idf.py b/hub/exports/building_energy/cerc_idf.py index b41d96d6..74b44753 100644 --- a/hub/exports/building_energy/cerc_idf.py +++ b/hub/exports/building_energy/cerc_idf.py @@ -61,6 +61,7 @@ class CercIdf(IdfBase): self._add_lighting = IdfLighting.add self._add_appliance = IdfAppliance.add self._add_infiltration = IdfInfiltration.add + self._add_infiltration_surface = IdfInfiltration.add_surface self._add_ventilation = IdfVentilation.add self._add_zone = IdfZone.add self._add_thermostat = IdfThermostat.add @@ -210,7 +211,10 @@ class CercIdf(IdfBase): 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) + if self._calculate_with_new_infiltration: # ToDo: Check with oriol if we want to keep the old method too + self._add_infiltration_surface(self, thermal_zone, building.name) + else: + 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) diff --git a/hub/exports/building_energy/idf_files/outputs.idf b/hub/exports/building_energy/idf_files/outputs.idf index d0442210..e2c97a39 100644 --- a/hub/exports/building_energy/idf_files/outputs.idf +++ b/hub/exports/building_energy/idf_files/outputs.idf @@ -47,6 +47,16 @@ OUTPUT:VARIABLE, Other Equipment Electricity Rate, !- Variable Name Hourly; !- Reporting Frequency +OUTPUT:VARIABLE, + *, !- Key Value + Zone Air Temperature, !- Variable Name + Hourly; !- Reporting Frequency + +OUTPUT:VARIABLE, + *, !- Key Value + Zone Air Relative Humidity, !- Variable Name + Hourly; !- Reporting Frequency + Output:Meter, DISTRICTHEATING:Facility, !- Key Name hourly; !- Reporting Frequency diff --git a/hub/exports/building_energy/idf_helper/idf_base.py b/hub/exports/building_energy/idf_helper/idf_base.py index ae761422..e5c5c283 100644 --- a/hub/exports/building_energy/idf_helper/idf_base.py +++ b/hub/exports/building_energy/idf_helper/idf_base.py @@ -5,7 +5,8 @@ import hub.exports.building_energy.idf_helper as idf_cte class IdfBase: - def __init__(self, city, output_path, idf_file_path, idd_file_path, epw_file_path, target_buildings=None): + def __init__(self, city, output_path, idf_file_path, idd_file_path, epw_file_path, target_buildings=None, + _calculate_with_new_infiltration=True): self._city = city self._output_path = str(output_path.resolve()) self._output_file_path = str((output_path / f'{city.name}.idf').resolve()) @@ -49,6 +50,7 @@ class IdfBase: building = city.city_object(building_name) if building.neighbours is not None: self._adjacent_buildings += building.neighbours + self._calculate_with_new_infiltration = _calculate_with_new_infiltration def _create_output_control_lighting(self): file = self._files['appliances'] diff --git a/hub/exports/building_energy/idf_helper/idf_infiltration.py b/hub/exports/building_energy/idf_helper/idf_infiltration.py index 2d010270..87d0e269 100644 --- a/hub/exports/building_energy/idf_helper/idf_infiltration.py +++ b/hub/exports/building_energy/idf_helper/idf_infiltration.py @@ -6,14 +6,22 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfInfiltration(IdfBase): @staticmethod def add(self, thermal_zone, zone_name): + IdfInfiltration._add_infiltration(self, thermal_zone, zone_name, 'AirChanges/Hour', cte.HOUR_TO_SECONDS) + + @staticmethod + def add_surface(self, thermal_zone, zone_name): + IdfInfiltration._add_infiltration(self, thermal_zone, zone_name, 'Flow/ExteriorWallArea', 1) + + @staticmethod + def _add_infiltration(self, thermal_zone, zone_name, calculation_method, multiplier): schedule_name = f'Infiltration schedules {thermal_zone.usage_name}' - infiltration = thermal_zone.infiltration_rate_system_off * cte.HOUR_TO_SECONDS + infiltration = thermal_zone.infiltration_rate_system_off * multiplier file = self._files['infiltration'] self._write_to_idf_format(file, idf_cte.INFILTRATION) self._write_to_idf_format(file, f'{zone_name}_infiltration', '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, 'AirChanges/Hour', 'Design Flow Rate Calculation Method') + self._write_to_idf_format(file, calculation_method, 'Design Flow Rate Calculation Method') self._write_to_idf_format(file, idf_cte.EMPTY, 'Design Flow Rate') self._write_to_idf_format(file, idf_cte.EMPTY, 'Flow Rate per Floor Area') self._write_to_idf_format(file, idf_cte.EMPTY, 'Flow Rate per Exterior Surface Area') @@ -21,4 +29,4 @@ class IdfInfiltration(IdfBase): self._write_to_idf_format(file, 1, 'Constant Term Coefficient') self._write_to_idf_format(file, 0, 'Temperature Term Coefficient') self._write_to_idf_format(file, 0, 'Velocity Term Coefficient') - self._write_to_idf_format(file, 0, 'Velocity Squared Term Coefficient', ';') \ No newline at end of file + self._write_to_idf_format(file, 0, 'Velocity Squared Term Coefficient', ';') diff --git a/hub/exports/building_energy/idf_helper/idf_window.py b/hub/exports/building_energy/idf_helper/idf_window.py index 4a86f97e..8539f92a 100644 --- a/hub/exports/building_energy/idf_helper/idf_window.py +++ b/hub/exports/building_energy/idf_helper/idf_window.py @@ -1,5 +1,4 @@ import logging -from copy import copy import hub.exports.building_energy.idf_helper as idf_cte import hub.helpers.constants as cte @@ -7,6 +6,7 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfWindow(IdfBase): + @staticmethod def _to_window_surface(self, surface): window_ratio = surface.associated_thermal_boundaries[0].window_ratio @@ -20,18 +20,14 @@ class IdfWindow(IdfBase): distance = (max_z - min_z) * window_ratio new_max_z = middle + distance / 2 new_min_z = middle - distance / 2 - window_coordinates = [] for index, coordinate in enumerate(coordinates): - if coordinate[z] == max_z: - new_coordinate = (coordinate[x], coordinate[y], new_max_z) + coordinates[index] = (coordinate[x], coordinate[y], new_max_z) elif coordinate[z] == min_z: - new_coordinate = (coordinate[x], coordinate[y], new_min_z) + coordinates[index] = (coordinate[x], coordinate[y], new_min_z) else: - new_coordinate = (coordinate[x], coordinate[y], coordinate[z]) - logging.info('error') - window_coordinates.insert(0, new_coordinate) # store in inverted order - return window_coordinates + logging.warning('Z coordinate not in top or bottom during window creation') + return coordinates @staticmethod def add(self, building): diff --git a/hub/imports/weather/EPWCLEANER b/hub/imports/weather/EPWCLEANER deleted file mode 100644 index e69de29b..00000000