/
vdi6007_case02_new_core.py
86 lines (63 loc) · 2.6 KB
/
vdi6007_case02_new_core.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
#!/usr/bin/env python
# coding=utf-8
"""
Run VDI 6007 test case 2
"""
import os
import numpy as np
from teaser.logic.simulation.vdi_core import VDICore
import teaser.examples.verification.vdi6007_testcases.vdi6007_case01 as vdic
from teaser.examples.verification.vdi6007_testcases.vdi6007shared import \
prepare_thermal_zone, hourly_average, plot_result, prepare_internal_gains_rad
def run_case2(plot_res=False):
"""
Run test case 2
Parameters
----------
plot_res : bool, optional
Defines, if results should be plotted (default: False)
Returns
-------
result_tuple : tuple (of floats)
Results tuple with maximal temperature deviations
(max_dev_1, max_dev_10, max_dev_60)
"""
# Definition of time horizon
times_per_hour = 60
timesteps = 24 * 60 * times_per_hour # 60 days
timesteps_day = int(24 * times_per_hour)
tz = prepare_thermal_zone(timesteps, room="S1")
calc = VDICore(tz)
calc.equal_air_temp = np.zeros(timesteps) + 295.15
calc.solar_rad_in = np.zeros((timesteps, 1))
calc.t_set_heating = np.zeros(timesteps) # in Kelvin
calc.t_set_cooling = np.zeros(timesteps) + 600 # in Kelvin
calc.heater_limit = np.zeros((timesteps, 3)) + 1e10
calc.cooler_limit = np.zeros((timesteps, 3)) - 1e10
calc.internal_gains_rad = prepare_internal_gains_rad(timesteps_day)
t_air, q_air_hc = calc.simulate()
T_air_mean = hourly_average(data=t_air-273.15, times_per_hour=times_per_hour)
T_air_1 = T_air_mean[0:24]
T_air_10 = T_air_mean[216:240]
T_air_60 = T_air_mean[1416:1440]
this_path = os.path.dirname(os.path.abspath(__file__))
ref_file = 'case02_res.csv'
ref_path = os.path.join(this_path, 'inputs', ref_file)
# Load reference results
(T_air_ref_1, T_air_ref_10, T_air_ref_60) = vdic.load_res(ref_path)
T_air_ref_1 = T_air_ref_1[:, 0]
T_air_ref_10 = T_air_ref_10[:, 0]
T_air_ref_60 = T_air_ref_60[:, 0]
if plot_res:
plot_result(T_air_1, T_air_ref_1, "Results day 1", "temperature")
plot_result(T_air_10, T_air_ref_10, "Results day 10", "temperature")
plot_result(T_air_60, T_air_ref_60, "Results day 60", "temperature")
max_dev_1 = np.max(np.abs(T_air_1 - T_air_ref_1))
max_dev_10 = np.max(np.abs(T_air_10 - T_air_ref_10))
max_dev_60 = np.max(np.abs(T_air_60 - T_air_ref_60))
print("Max. deviation day 1: " + str(max_dev_1))
print("Max. deviation day 10: " + str(max_dev_10))
print("Max. deviation day 60: " + str(max_dev_60))
return (max_dev_1, max_dev_10, max_dev_60)
if __name__ == '__main__':
run_case2(plot_res=True)