-
Notifications
You must be signed in to change notification settings - Fork 14
/
test_building_manual_calculation_thermal_conductances.py
117 lines (104 loc) · 4.13 KB
/
test_building_manual_calculation_thermal_conductances.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""Test for manual calculation of thermal conductances H_tr in building module.
The aim is to implement scalability in the building module by scaling up the area of the building.
Therefore some functions must be adjusted which are tested here before.
"""
# clean
import numpy as np
import pytest
from hisim.components import building
from hisim.simulationparameters import SimulationParameters
from hisim import utils
# # in case you want to check on all TABULA buildings -> run test over all building_codes
# d_f = pd.read_csv(
# utils.HISIMPATH["housing"],
# decimal=",",
# sep=";",
# encoding="cp1252",
# low_memory=False,
# )
# for building_code in d_f["Code_BuildingVariant"]:
# if isinstance(building_code, str):
# my_residence_config.building_code = building_code
# my_residence = building.Building(
# config=my_residence_config, my_simulation_parameters=my_simulation_parameters)
# log.information(building_code)
@pytest.mark.buildingtest
@utils.measure_execution_time
def test_building_thermal_conductance_calculation():
"""Test function for some functions of the building module."""
building_code = "DE.N.SFH.05.Gen.ReEx.001.001"
building_heat_capacity_class = "medium"
seconds_per_timestep = 60
my_simulation_parameters = SimulationParameters.one_day_only(
year=2021, seconds_per_timestep=seconds_per_timestep
)
# Set Residence
my_residence_config = (
building.BuildingConfig.get_default_german_single_family_home()
)
my_residence_config.building_code = building_code
my_residence_config.building_heat_capacity_class = building_heat_capacity_class
my_residence = building.Building(
config=my_residence_config, my_simulation_parameters=my_simulation_parameters
)
# Test calculation of the thermal conductances H_Transmission (H_tr) given by TABULA
# building function: get_thermal_conductance_between_exterior_and_windows_and_door_in_watt_per_kelvin
w_s = [
"Window_1",
"Window_2",
"Door_1",
]
list_h_tr_window = []
list_h_tr_window_calculated = []
k = 0
for w_i in w_s:
list_h_tr_window.append(
my_residence.my_building_information.buildingdata[
"H_Transmission_" + w_i
].values[0]
)
# with H_Tr = U * A * b_tr [W/K] -> by calculating H_tr manually one can later scale this up by scaling up A_Calc
h_tr_i = (
my_residence.my_building_information.buildingdata["U_Actual_" + w_i].values[
0
]
* my_residence.my_building_information.buildingdata["A_" + w_i].values[0]
* 1.0
)
list_h_tr_window_calculated.append(h_tr_i)
k = k + 1
# check if calculated H_tr is equal to H_tr which was read from buildingdata directly
np.testing.assert_allclose(list_h_tr_window, list_h_tr_window_calculated, atol=0.02)
# builing function: get_thermal_conductance_of_opaque_surfaces_in_watt_per_kelvin
opaque_walls = [
"Wall_1",
"Wall_2",
"Wall_3",
"Roof_1",
"Roof_2",
"Floor_1",
"Floor_2",
]
list_h_tr_opaque = []
list_h_tr_opaque_calculated = []
k = 0
for o_p in opaque_walls:
list_h_tr_opaque.append(
my_residence.my_building_information.buildingdata[
"H_Transmission_" + o_p
].values[0]
)
# with H_Tr = U * A * b_tr [W/K] -> by calculating H_tr manually one can later scale this up by scaling up A_Calc
h_tr_i = (
my_residence.my_building_information.buildingdata["U_Actual_" + o_p].values[
0
]
* my_residence.my_building_information.buildingdata["A_" + o_p].values[0]
* my_residence.my_building_information.buildingdata[
"b_Transmission_" + o_p
].values[0]
)
list_h_tr_opaque_calculated.append(h_tr_i)
k = k + 1
# check if calculated H_tr is equal to H_tr which was read from buildingdata directly
np.testing.assert_allclose(list_h_tr_window, list_h_tr_window_calculated, atol=0.02)