complete refactor
This commit is contained in:
parent
16b0726db7
commit
afe5e433ea
@ -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()
|
||||
|
@ -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'
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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}'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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']
|
||||
|
@ -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
|
||||
|
@ -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}'
|
||||
|
@ -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
|
||||
|
9
hub/exports/building_energy/idf_helper/idf_window.py
Normal file
9
hub/exports/building_energy/idf_helper/idf_window.py
Normal file
@ -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
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user