Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix default parameters for calc_building_parameter class #802

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion teaser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import os

__version__ = "1.1.1"
__version__ = "1.1.2"


new_path = os.path.join(os.path.expanduser('~'), ("TEASEROutput"))
Expand Down
36 changes: 25 additions & 11 deletions teaser/logic/buildingobjects/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ def fill_window_area_dict(self):
self.window_area[key] = self.get_window_area(key)

def calc_building_parameter(
self, number_of_elements=2, merge_windows=False, used_library="AixLib"
self,
number_of_elements=None,
merge_windows=None,
used_library=None
):
"""calc all building parameters

Expand All @@ -378,19 +381,30 @@ def calc_building_parameter(

Parameters
----------
number_of_elements : int
number_of_elements : int, optional
defines the number of elements, that area aggregated, between 1
and 4, default is 2
merge_windows : bool
and 4. If None, uses existing class property
merge_windows : bool, optional
True for merging the windows into the outer walls, False for
separate resistance for window, default is False
used_library : str
used library (AixLib and IBPSA are supported)
separate resistance for window. If None, uses existing class
property
used_library : str, optional
used library (AixLib and IBPSA are supported). If None, uses
existing class property
"""

self._number_of_elements_calc = number_of_elements
self._merge_windows_calc = merge_windows
self._used_library_calc = used_library
# Use provided values or fall back to existing class properties
number_of_elements = (
number_of_elements if number_of_elements is not None
else self._number_of_elements_calc)
merge_windows = (merge_windows if merge_windows is not None
else self._merge_windows_calc)
used_library = used_library if used_library is not None else (
self._used_library_calc)

# Update class properties with the values being used
self.number_of_elements_calc = number_of_elements
self.merge_windows_calc = merge_windows
self.used_library_calc = used_library

self.area_rt = 0
self.area_gf = 0
Expand Down
85 changes: 85 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
@author: TEASER 4 Development Team
"""
from teaser.logic import utilities
from teaser.logic.buildingobjects.calculation.four_element import FourElement
from teaser.logic.buildingobjects.calculation.three_element import ThreeElement
from teaser.logic.buildingobjects.calculation.two_element import TwoElement
from teaser.project import Project
from teaser.data.utilities import ConstructionData
from teaser.data.dataclass import DataClass
Expand All @@ -15,10 +18,12 @@
prj = Project(False)
prj.data = DataClass(construction_data=ConstructionData.iwu_heavy)


class Test_teaser(object):
"""Unit Tests for TEASER"""

global prj

def test_calc_vdi_room1(self):
"""Parameter Verification for rouvel room1"""
import teaser.examples.verification.verification_VDI_6007_room1 as room1
Expand Down Expand Up @@ -625,6 +630,86 @@ def test_calc_all_buildings(self):
prj.used_library_calc = "AixLib"
prj.calc_all_buildings(raise_errors=True)

def test_number_of_elements_propagation(self):
"""Tests propagation of changes in number_of_elements_calc"""

helptest.building_test2(prj)
prj.number_of_elements_calc = 2
prj.merge_windows_calc = False
prj.used_library_calc = "AixLib"
prj.calc_all_buildings(raise_errors=True)

assert prj.number_of_elements_calc == 2
bldg = prj.buildings[-1]
assert bldg.number_of_elements_calc == 2
tz = bldg.thermal_zones[0]
assert isinstance(tz.model_attr, TwoElement)
assert not hasattr(tz.model_attr, 'area_gf')
assert not hasattr(tz.model_attr, 'area_rt')

prj.number_of_elements_calc = 3
prj.calc_all_buildings(raise_errors=True)

assert prj.number_of_elements_calc == 3
bldg = prj.buildings[-1]
assert bldg.number_of_elements_calc == 3
tz = bldg.thermal_zones[0]
assert isinstance(tz.model_attr, ThreeElement)
assert tz.model_attr.area_gf == 140.0
assert not hasattr(tz.model_attr, 'area_rt')

prj.number_of_elements_calc = 4
prj.calc_all_buildings(raise_errors=True)

assert prj.number_of_elements_calc == 4
bldg = prj.buildings[-1]
assert bldg.number_of_elements_calc == 4
tz = bldg.thermal_zones[0]
assert isinstance(tz.model_attr, FourElement)
assert tz.model_attr.area_rt == 140.0
assert tz.model_attr.area_gf == 140.0

def test_calc_building_parameter(self):
"""Check that calc_building_parameter() not overwrites prj settings"""
helptest.building_test2(prj)
prj.number_of_elements_calc = 2
prj.merge_windows_calc = False
prj.used_library_calc = "AixLib"
prj.calc_all_buildings(raise_errors=True)

assert prj.number_of_elements_calc == 2
bldg = prj.buildings[-1]
assert bldg.number_of_elements_calc == 2
bldg.calc_building_parameter()
tz = bldg.thermal_zones[0]
assert isinstance(tz.model_attr, TwoElement)
assert not hasattr(tz.model_attr, 'area_gf')
assert not hasattr(tz.model_attr, 'area_rt')

prj.number_of_elements_calc = 3
prj.calc_all_buildings(raise_errors=True)

assert prj.number_of_elements_calc == 3
bldg = prj.buildings[-1]
assert bldg.number_of_elements_calc == 3
bldg.calc_building_parameter()
tz = bldg.thermal_zones[0]
assert isinstance(tz.model_attr, ThreeElement)
assert tz.model_attr.area_gf == 140.0
assert not hasattr(tz.model_attr, 'area_rt')

prj.number_of_elements_calc = 4
prj.calc_all_buildings(raise_errors=True)

assert prj.number_of_elements_calc == 4
bldg = prj.buildings[-1]
assert bldg.number_of_elements_calc == 4
bldg.calc_building_parameter()
tz = bldg.thermal_zones[0]
assert isinstance(tz.model_attr, FourElement)
assert tz.model_attr.area_rt == 140.0
assert tz.model_attr.area_gf == 140.0

def test_retrofit_all_buildings(self):
"""test of retrofit_all_buildings, no calculation verification"""
prj.add_residential(
Expand Down
Loading