Include oriol's infiltration changes into cerc_idf and remove empty file

This commit is contained in:
Guille Gutierrez 2024-11-08 06:41:15 +01:00
parent c804c5ee6a
commit 14404fbf04
6 changed files with 34 additions and 14 deletions

View File

@ -61,6 +61,7 @@ class CercIdf(IdfBase):
self._add_lighting = IdfLighting.add self._add_lighting = IdfLighting.add
self._add_appliance = IdfAppliance.add self._add_appliance = IdfAppliance.add
self._add_infiltration = IdfInfiltration.add self._add_infiltration = IdfInfiltration.add
self._add_infiltration_surface = IdfInfiltration.add_surface
self._add_ventilation = IdfVentilation.add self._add_ventilation = IdfVentilation.add
self._add_zone = IdfZone.add self._add_zone = IdfZone.add
self._add_thermostat = IdfThermostat.add self._add_thermostat = IdfThermostat.add
@ -210,6 +211,9 @@ class CercIdf(IdfBase):
self._add_occupancy(self, thermal_zone, building.name) self._add_occupancy(self, thermal_zone, building.name)
self._add_lighting(self, thermal_zone, building.name) self._add_lighting(self, thermal_zone, building.name)
self._add_appliance(self, thermal_zone, building.name) self._add_appliance(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_infiltration(self, thermal_zone, building.name)
self._add_ventilation(self, thermal_zone, building.name) self._add_ventilation(self, thermal_zone, building.name)
self._add_thermostat(self, thermal_zone) self._add_thermostat(self, thermal_zone)

View File

@ -47,6 +47,16 @@ OUTPUT:VARIABLE,
Other Equipment Electricity Rate, !- Variable Name Other Equipment Electricity Rate, !- Variable Name
Hourly; !- Reporting Frequency 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, Output:Meter,
DISTRICTHEATING:Facility, !- Key Name DISTRICTHEATING:Facility, !- Key Name
hourly; !- Reporting Frequency hourly; !- Reporting Frequency

View File

@ -5,7 +5,8 @@ import hub.exports.building_energy.idf_helper as idf_cte
class IdfBase: 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._city = city
self._output_path = str(output_path.resolve()) self._output_path = str(output_path.resolve())
self._output_file_path = str((output_path / f'{city.name}.idf').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) building = city.city_object(building_name)
if building.neighbours is not None: if building.neighbours is not None:
self._adjacent_buildings += building.neighbours self._adjacent_buildings += building.neighbours
self._calculate_with_new_infiltration = _calculate_with_new_infiltration
def _create_output_control_lighting(self): def _create_output_control_lighting(self):
file = self._files['appliances'] file = self._files['appliances']

View File

@ -6,14 +6,22 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfInfiltration(IdfBase): class IdfInfiltration(IdfBase):
@staticmethod @staticmethod
def add(self, thermal_zone, zone_name): 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}' 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'] file = self._files['infiltration']
self._write_to_idf_format(file, idf_cte.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, 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, 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')
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, '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 Floor Area')
self._write_to_idf_format(file, idf_cte.EMPTY, 'Flow Rate per Exterior Surface Area') self._write_to_idf_format(file, idf_cte.EMPTY, 'Flow Rate per Exterior Surface Area')

View File

@ -1,5 +1,4 @@
import logging import logging
from copy import copy
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
import hub.helpers.constants as 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): class IdfWindow(IdfBase):
@staticmethod @staticmethod
def _to_window_surface(self, surface): def _to_window_surface(self, surface):
window_ratio = surface.associated_thermal_boundaries[0].window_ratio window_ratio = surface.associated_thermal_boundaries[0].window_ratio
@ -20,18 +20,14 @@ class IdfWindow(IdfBase):
distance = (max_z - min_z) * window_ratio distance = (max_z - min_z) * window_ratio
new_max_z = middle + distance / 2 new_max_z = middle + distance / 2
new_min_z = middle - distance / 2 new_min_z = middle - distance / 2
window_coordinates = []
for index, coordinate in enumerate(coordinates): for index, coordinate in enumerate(coordinates):
if coordinate[z] == max_z: 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: elif coordinate[z] == min_z:
new_coordinate = (coordinate[x], coordinate[y], new_min_z) coordinates[index] = (coordinate[x], coordinate[y], new_min_z)
else: else:
new_coordinate = (coordinate[x], coordinate[y], coordinate[z]) logging.warning('Z coordinate not in top or bottom during window creation')
logging.info('error') return coordinates
window_coordinates.insert(0, new_coordinate) # store in inverted order
return window_coordinates
@staticmethod @staticmethod
def add(self, building): def add(self, building):