rewritten thermal_openings creation to allow change in window ratio (doing it wrong previously)

This commit is contained in:
Pilar Monsalvete 2023-07-17 17:26:47 -04:00
parent 2744f86c66
commit 285c819d31
2 changed files with 65 additions and 39 deletions

View File

@ -36,7 +36,9 @@ class ThermalBoundary:
self._thickness = None self._thickness = None
self._internal_surface = None self._internal_surface = None
self._window_ratio = None self._window_ratio = None
self._window_ratio_is_calculated = False self._window_ratio_to_be_calculated = False
if self._windows_areas is not None:
self._window_ratio_to_be_calculated = True
@property @property
def id(self): def id(self):
@ -101,6 +103,16 @@ class ThermalBoundary:
:return: None or [ThermalOpening] :return: None or [ThermalOpening]
""" """
if self._thermal_openings is None: if self._thermal_openings is None:
if self.windows_areas is not None:
if len(self.windows_areas) > 0:
self._thermal_openings = []
for window_area in self.windows_areas:
thermal_opening = ThermalOpening()
thermal_opening.area = window_area
self._thermal_openings.append(thermal_opening)
else:
self._thermal_openings = []
else:
if self.window_ratio is not None: if self.window_ratio is not None:
if self.window_ratio == 0: if self.window_ratio == 0:
self._thermal_openings = [] self._thermal_openings = []
@ -113,14 +125,29 @@ class ThermalBoundary:
thermal_opening.area = _area thermal_opening.area = _area
self._thermal_openings = [thermal_opening] self._thermal_openings = [thermal_opening]
else: else:
if len(self.windows_areas) > 0:
self._thermal_openings = [] self._thermal_openings = []
for window_area in self.windows_areas:
thermal_opening = ThermalOpening()
thermal_opening.area = window_area
self._thermal_openings.append(thermal_opening)
else: else:
if self.windows_areas is not None:
return self._thermal_openings
if self.window_ratio is not None:
if self.window_ratio == 0:
self._thermal_openings = [] self._thermal_openings = []
else:
if len(self._thermal_openings) == 0:
thermal_opening = ThermalOpening()
if self.window_ratio == 1:
_area = self.opaque_area
else:
_area = self.opaque_area * self.window_ratio / (1-self.window_ratio)
thermal_opening.area = _area
self._thermal_openings = [thermal_opening]
else:
for _thermal_opening in self._thermal_openings:
if self.window_ratio == 1:
_area = self.opaque_area
else:
_area = self.opaque_area * self.window_ratio / (1-self.window_ratio)
_thermal_opening.area = _area
return self._thermal_openings return self._thermal_openings
@property @property
@ -174,9 +201,7 @@ class ThermalBoundary:
If none of those sources are available, it returns None. If none of those sources are available, it returns None.
:return: float :return: float
""" """
if self.windows_areas is not None: if self._window_ratio_to_be_calculated:
if not self._window_ratio_is_calculated:
_calculated = True
if len(self.windows_areas) == 0: if len(self.windows_areas) == 0:
self._window_ratio = 0 self._window_ratio = 0
else: else:
@ -192,7 +217,7 @@ class ThermalBoundary:
Set thermal boundary window ratio Set thermal boundary window ratio
:param value: str :param value: str
""" """
if self._window_ratio_is_calculated: if self._window_ratio_to_be_calculated:
raise ValueError('Window ratio cannot be assigned when the windows are defined in the geometry.') raise ValueError('Window ratio cannot be assigned when the windows are defined in the geometry.')
self._window_ratio = float(value) self._window_ratio = float(value)

View File

@ -44,21 +44,21 @@ class InselMonthlyEnergyBalance:
self._insel_files_paths.append(building.name + '.insel') self._insel_files_paths.append(building.name + '.insel')
file_name_out = building.name + '.out' file_name_out = building.name + '.out'
output_path = Path(self._path / file_name_out).resolve() output_path = Path(self._path / file_name_out).resolve()
if building.internal_zones is not None: if building.thermal_zones is None:
for internal_zone in building.internal_zones:
if internal_zone.thermal_zones is None:
logging.warning('Building %s has missing values. Monthly Energy Balance cannot be processed', building.name) logging.warning('Building %s has missing values. Monthly Energy Balance cannot be processed', building.name)
break
self._contents.append( self._contents.append(
self._generate_meb_template(building, output_path, self._radiation_calculation_method, self._weather_format, self._custom_insel_block) self._generate_meb_template(building, output_path, self._radiation_calculation_method, self._weather_format, self._custom_insel_block)
) )
self._export() self._export()
@staticmethod @staticmethod
def _add_block(file, block_number, block_type, inputs='', parameters=''): def _add_block(file, block_number, block_type, inputs=None, parameters=None):
file += "S " + str(block_number) + " " + block_type + "\n" file += "S " + str(block_number) + " " + block_type + "\n"
if inputs is not None:
for block_input in inputs: for block_input in inputs:
file += str(block_input) + "\n" file += str(block_input) + "\n"
if parameters is not None:
if len(parameters) > 0: if len(parameters) > 0:
file += "P " + str(block_number) + "\n" file += "P " + str(block_number) + "\n"
for block_parameter in parameters: for block_parameter in parameters:
@ -222,6 +222,7 @@ class InselMonthlyEnergyBalance:
parameters.append(0.0) parameters.append(0.0)
parameters.append(0.0) parameters.append(0.0)
else: else:
print(window_area, thermal_boundary.thermal_openings)
thermal_opening = thermal_boundary.thermal_openings[0] thermal_opening = thermal_boundary.thermal_openings[0]
parameters.append(thermal_opening.frame_ratio) parameters.append(thermal_opening.frame_ratio)
parameters.append(thermal_opening.overall_u_value) parameters.append(thermal_opening.overall_u_value)