correct refactor

This commit is contained in:
Guille Gutierrez 2024-10-03 13:56:01 +02:00
parent b915dbdead
commit 16b0726db7
19 changed files with 38 additions and 38 deletions

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfAppliance(CercIdf): class IdfAppliance(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
schedule_name = f'Appliance schedules {thermal_zone.usage_name}' schedule_name = f'Appliance schedules {thermal_zone.usage_name}'
storeys_number = int(thermal_zone.total_floor_area / thermal_zone.footprint_area) storeys_number = int(thermal_zone.total_floor_area / thermal_zone.footprint_area)

View File

@ -1,9 +1,9 @@
from hub.city_model_structure.building_demand.layer import Layer
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.city_model_structure.building_demand.layer import Layer
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfConstruction(CercIdf): class IdfConstruction(IdfBase):
def _add_solid_material(self, layer): def _add_solid_material(self, layer):
file = self._files['solid_materials'] file = self._files['solid_materials']
self._write_to_idf_format(file, idf_cte.SOLID_MATERIAL) self._write_to_idf_format(file, idf_cte.SOLID_MATERIAL)

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfDhw(CercIdf): class IdfDhw(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
name = f'DHW {zone_name}' name = f'DHW {zone_name}'
peak_flow_rate = thermal_zone.domestic_hot_water.peak_flow * thermal_zone.total_floor_area peak_flow_rate = thermal_zone.domestic_hot_water.peak_flow * thermal_zone.total_floor_area

View File

@ -1,10 +1,10 @@
from pathlib import Path from pathlib import Path
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
from hub.exports.building_energy.cerc_idf import CercIdf
class IdfFileSchedule(CercIdf): class IdfFileSchedule(IdfBase):
def add(self, usage, schedule_type, schedules): def add(self, usage, schedule_type, schedules):
schedule_name = f'{schedule_type} schedules {usage}' schedule_name = f'{schedule_type} schedules {usage}'
for schedule in schedules: for schedule in schedules:

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfHeatingSystem(CercIdf): class IdfHeatingSystem(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
availability_schedule = f'HVAC AVAIL SCHEDULES {thermal_zone.usage_name}' availability_schedule = f'HVAC AVAIL SCHEDULES {thermal_zone.usage_name}'
thermostat_name = f'Thermostat {thermal_zone.usage_name}' thermostat_name = f'Thermostat {thermal_zone.usage_name}'

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfInfiltration(CercIdf): class IdfInfiltration(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
schedule_name = f'Infiltration schedules {thermal_zone.usage_name}' schedule_name = f'Infiltration schedules {thermal_zone.usage_name}'

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfLighting(CercIdf): class IdfLighting(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
storeys_number = int(thermal_zone.total_floor_area / thermal_zone.footprint_area) storeys_number = int(thermal_zone.total_floor_area / thermal_zone.footprint_area)
watts_per_zone_floor_area = thermal_zone.lighting.density * storeys_number watts_per_zone_floor_area = thermal_zone.lighting.density * storeys_number

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfMaterial(CercIdf): class IdfMaterial(IdfBase):
def _add_solid_material(self, layer): def _add_solid_material(self, layer):
file = self._files['solid_materials'] file = self._files['solid_materials']
self._write_to_idf_format(file, idf_cte.SOLID_MATERIAL) self._write_to_idf_format(file, idf_cte.SOLID_MATERIAL)

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfOccupancy(CercIdf): class IdfOccupancy(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
number_of_people = thermal_zone.occupancy.occupancy_density * thermal_zone.total_floor_area number_of_people = thermal_zone.occupancy.occupancy_density * thermal_zone.total_floor_area
fraction_radiant = 0 fraction_radiant = 0

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfSchedule(CercIdf): class IdfSchedule(IdfBase):
def add(self, usage, schedule_type, schedules): def add(self, usage, schedule_type, schedules):
if len(schedules) < 1: if len(schedules) < 1:
return return

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfShading(CercIdf): class IdfShading(IdfBase):
def add(self, building): def add(self, building):
name = building.name name = building.name
file = self._files['shading'] file = self._files['shading']

View File

@ -1,9 +1,9 @@
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
from hub.exports.building_energy.cerc_idf import CercIdf from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfSurfaces(CercIdf): class IdfSurfaces(IdfBase):
def add(self, building, zone_name): def add(self, building, zone_name):
# Verify if create building surfaces "by hand" it's faster wwr it's missing # Verify if create building surfaces "by hand" it's faster wwr it's missing
zone_name = f'{zone_name}' zone_name = f'{zone_name}'

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfThermostat(CercIdf): class IdfThermostat(IdfBase):
def add(self, thermal_zone): def add(self, thermal_zone):
thermostat_name = f'Thermostat {thermal_zone.usage_name}' thermostat_name = f'Thermostat {thermal_zone.usage_name}'

View File

@ -1,9 +1,9 @@
from hub.exports.building_energy.cerc_idf import CercIdf
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
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfVentilation(CercIdf): class IdfVentilation(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
schedule_name = f'Ventilation schedules {thermal_zone.usage_name}' schedule_name = f'Ventilation schedules {thermal_zone.usage_name}'
air_change = thermal_zone.mechanical_air_change * cte.HOUR_TO_SECONDS air_change = thermal_zone.mechanical_air_change * cte.HOUR_TO_SECONDS

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfWindowsConstructions(CercIdf): class IdfWindowsConstructions(IdfBase):
def add(self): def add(self):
glazing_index = self._windows_added_to_idf['glazing_index'] + 1 glazing_index = self._windows_added_to_idf['glazing_index'] + 1
for i in range(1, glazing_index): for i in range(1, glazing_index):

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfWindowsMaterial(CercIdf): class IdfWindowsMaterial(IdfBase):
def add(self, thermal_opening): def add(self, thermal_opening):
name = f'{thermal_opening.overall_u_value}_{thermal_opening.g_value}' name = f'{thermal_opening.overall_u_value}_{thermal_opening.g_value}'
if name not in self._windows_added_to_idf: if name not in self._windows_added_to_idf:

View File

@ -1,8 +1,8 @@
from hub.exports.building_energy.cerc_idf import CercIdf
import hub.exports.building_energy.idf_helper as idf_cte import hub.exports.building_energy.idf_helper as idf_cte
from hub.exports.building_energy.idf_helper.idf_base import IdfBase
class IdfZone(CercIdf): class IdfZone(IdfBase):
def add(self, thermal_zone, zone_name): def add(self, thermal_zone, zone_name):
file = self._files['zones'] file = self._files['zones']
self._write_to_idf_format(file, idf_cte.ZONE) self._write_to_idf_format(file, idf_cte.ZONE)

View File

@ -11,7 +11,7 @@ import requests
from hub.exports.building_energy.energy_ade import EnergyAde from hub.exports.building_energy.energy_ade import EnergyAde
from hub.exports.building_energy.idf import Idf from hub.exports.building_energy.idf import Idf
from hub.exports.building_energy.idf_helper import CercIdf from hub.exports.building_energy.cerc_idf import CercIdf
from hub.exports.building_energy.insel.insel_monthly_energy_balance import InselMonthlyEnergyBalance from hub.exports.building_energy.insel.insel_monthly_energy_balance import InselMonthlyEnergyBalance
from hub.helpers.utils import validate_import_export_type from hub.helpers.utils import validate_import_export_type
from hub.imports.weather.helpers.weather import Weather as wh from hub.imports.weather.helpers.weather import Weather as wh

View File

@ -144,7 +144,7 @@ class TestExports(TestCase):
UsageFactory('nrcan', city).enrich() UsageFactory('nrcan', city).enrich()
WeatherFactory('epw', city).enrich() WeatherFactory('epw', city).enrich()
try: try:
EnergyBuildingsExportsFactory('idf_helper', city, self._output_path)._cerc_idf EnergyBuildingsExportsFactory('cerc_idf', city, self._output_path)._cerc_idf
except Exception: except Exception:
self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!") self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!")