Merge branch 'bug_thermal_zone' into 'master'

Bug thermal zone

See merge request Guille/hub!27
This commit is contained in:
Guillermo Gutierrez Morote 2022-11-01 13:59:32 +00:00
commit 41c66106fa
6 changed files with 228 additions and 220 deletions

View File

@ -292,6 +292,7 @@ class Surface:
Divides a surface at Z plane
:return: Surface, Surface, Any
"""
# todo: check return types
# todo: recheck this method for LoD3 (windows)
origin = Point([0, 0, z])
normal = np.array([0, 0, 1])

View File

@ -32,18 +32,17 @@ class ThermalBoundary:
self._outside_thermal_absorptance = None
self._outside_visible_absorptance = None
self._u_value = None
self._shortwave_reflectance = None
self._outside_shortwave_reflectance = None
self._construction_name = None
self._hi = ch().convective_heat_transfer_coefficient_interior
self._he = ch().convective_heat_transfer_coefficient_exterior
self._refurbishment_measure = None
self._thickness = None
self._virtual_internal_surface = None
self._inside_emissivity = None
self._alpha_coefficient = None
self._radiative_coefficient = None
self._window_ratio = None
self._window_ration_is_calculated = False
self._window_ratio_is_calculated = False
self._vegetation = None
@property
@ -135,7 +134,7 @@ class ThermalBoundary:
"""
if value is not None:
self._outside_solar_absorptance = float(value)
self._shortwave_reflectance = 1.0 - float(value)
self._outside_shortwave_reflectance = 1.0 - float(value)
@property
def outside_thermal_absorptance(self) -> Union[None, float]:
@ -252,7 +251,7 @@ class ThermalBoundary:
:return: float
"""
if self.windows_areas is not None:
if not self._window_ration_is_calculated:
if not self._window_ratio_is_calculated:
_calculated = True
if len(self.windows_areas) == 0:
self._window_ratio = 0
@ -269,7 +268,7 @@ class ThermalBoundary:
Set thermal boundary window ratio
:param value: str
"""
if self._window_ration_is_calculated:
if self._window_ratio_is_calculated:
raise ValueError('Window ratio cannot be assigned when the windows are defined in the geometry.')
self._window_ratio = float(value)
@ -313,21 +312,21 @@ class ThermalBoundary:
self._u_value = float(value)
@property
def shortwave_reflectance(self) -> Union[None, float]:
def outside_shortwave_reflectance(self) -> Union[None, float]:
"""
Get thermal boundary shortwave reflectance
Get thermal boundary external shortwave reflectance
:return: None or float
"""
return self._shortwave_reflectance
return self._outside_shortwave_reflectance
@shortwave_reflectance.setter
def shortwave_reflectance(self, value):
@outside_shortwave_reflectance.setter
def outside_shortwave_reflectance(self, value):
"""
Set thermal boundary shortwave reflectance
Set thermal boundary external shortwave reflectance
:param value: float
"""
if value is not None:
self._shortwave_reflectance = float(value)
self._outside_shortwave_reflectance = float(value)
self._outside_solar_absorptance = 1.0 - float(value)
@property

View File

@ -309,6 +309,7 @@ class ThermalZone:
if self.usage_zones is None:
return None
if self._occupancy is None:
self._occupancy = Occupancy()
_occupancy_density = 0
_convective_part = 0
@ -352,6 +353,7 @@ class ThermalZone:
if self.usage_zones is None:
return None
if self._lighting is None:
self._lighting = Lighting()
_lighting_density = 0
_convective_part = 0
@ -403,6 +405,7 @@ class ThermalZone:
if self.usage_zones is None:
return None
if self._appliances is None:
self._appliances = Appliances()
_appliances_density = 0
_convective_part = 0
@ -454,6 +457,7 @@ class ThermalZone:
if self.usage_zones is None:
return None
if self._internal_gains is None:
_internal_gain = InternalGain()
_days = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY, cte.SATURDAY, cte.SUNDAY, cte.HOLIDAY]
_average_internal_gain = 0
@ -512,6 +516,7 @@ class ThermalZone:
if self.usage_zones is None:
return None
if self._thermal_control is None:
self._thermal_control = ThermalControl()
_mean_heating_set_point = 0
_heating_set_back = 0

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<buildingUsageLibrary>
<name>Building Usage Library Reduced</name>
<description>Library created by Rabeeh from whatever norm</description>
<description>Library created by Sanam from HOT200 and ecobee</description>
<source>https://www.engineeringtoolbox.com/metabolic-heat-persons-d_706.html</source>
<zoneUsageType>
<id>residential</id>

View File

@ -236,14 +236,17 @@ class Idf:
self._idf.newidfobject(self._COMPACT_SCHEDULE, **_kwargs)
return
def _add_schedules(self, usage, schedule_type, new_schedules, schedule_from_file=False):
def _add_schedules(self, usage, schedule_type, new_schedules):
schedule_from_file = False
for schedule in new_schedules:
if len(schedule.values) > 168: # Hours in one week
schedule_from_file = True
if schedule_from_file:
new_schedule = new_schedules[0]
for schedule in self._idf.idfobjects[self._FILE_SCHEDULE]:
if schedule.Name == f'{schedule_type} schedules {usage}':
return
file_name = self._write_schedules_file(usage, new_schedule)
return self._add_file_schedule(usage, new_schedule, file_name)
file_name = self._write_schedules_file(usage, new_schedules[0])
return self._add_file_schedule(usage, new_schedules[0], file_name)
else:
for schedule in self._idf.idfobjects[self._HOURLY_SCHEDULE]:
if schedule.Name == f'{schedule_type} schedules {usage}':
@ -385,7 +388,7 @@ class Idf:
self._add_window_construction_and_material(thermal_opening)
usage = thermal_zone.usage
self._add_infiltration_schedules(thermal_zone)
self._add_schedules(usage, 'Occupancy', thermal_zone.occupancy.occupancy_schedules, schedule_from_file=True)
self._add_schedules(usage, 'Occupancy', thermal_zone.occupancy.occupancy_schedules)
self._add_schedules(usage, 'HVAC AVAIL', thermal_zone.thermal_control.hvac_availability_schedules)
self._add_schedules(usage, 'Heating thermostat', thermal_zone.thermal_control.heating_set_point_schedules)
self._add_schedules(usage, 'Cooling thermostat', thermal_zone.thermal_control.cooling_set_point_schedules)

View File

@ -106,7 +106,7 @@ class TestConstructionFactory(TestCase):
self.assertIsNotNone(thermal_boundary.thickness, 'thermal_boundary thickness is none')
self.assertIsNotNone(thermal_boundary.type, 'thermal_boundary type is none')
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
self.assertIsNotNone(thermal_boundary.shortwave_reflectance, 'shortwave_reflectance is none')
self.assertIsNotNone(thermal_boundary.outside_shortwave_reflectance, 'shortwave_reflectance is none')
self.assertIsNotNone(thermal_boundary.thermal_openings, 'thermal_openings is none')
self.assertIsNotNone(thermal_boundary.construction_name, 'construction_name is none')
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')