forked from ibpsa/project1-boptest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_bestest_hydronic_heat_pump.py
102 lines (79 loc) · 3.19 KB
/
test_bestest_hydronic_heat_pump.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
# -*- coding: utf-8 -*-
"""
This module runs tests for bestest_hydronic_heat_pump.
To run these tests, testcase bestest_hydronic_heat_pump must already
be deployed.
"""
import unittest
import pandas as pd
import os
import utilities
import requests
class Run(unittest.TestCase, utilities.partialTestTimePeriod, utilities.partialTestSeason):
'''Tests the example test case.
'''
def setUp(self):
'''Setup for each test.
'''
self.name = 'bestest_hydronic_heat_pump'
self.url = 'http:https://127.0.0.1:5000'
self.points_check = ['reaPFan_y', 'reaQHeaPumCon_y',
'reaTRet_y', 'reaQHeaPumEva_y',
'ovePum_u', 'reaTZon_y',
'reaTSup_y', 'reaPPumEmi_y',
'oveFan_u', 'reaPHeaPum_y',
'oveHeaPumY_u', 'reaQFloHea_y',
'reaCOP_y']
def test_peak_heat_day(self):
self.run_time_period('peak_heat_day')
def test_typical_heat_day(self):
self.run_time_period('typical_heat_day')
def test_summer(self):
self.run_season('summer')
def test_shoulder(self):
self.run_season('shoulder')
def test_event(self):
'''Runs the example to test for correct event handling.
Parameters
----------
None
Returns
-------
None
'''
start_time = 118*24*3600
length = 48*3600/12
# Initialize test case
requests.put('{0}/initialize'.format(self.url), json={'start_time':start_time, 'warmup_period':0})
# Get default simulation step
step_def = requests.get('{0}/step'.format(self.url)).json()['payload']
# Simulation Loop
for i in range(int(length/step_def)):
# Advance simulation
#switch pump on/off for each timestep
pump = 0 if (i % 2) == 0 else 1
u = {'ovePum_activate':1, 'ovePum_u':pump}
requests.post('{0}/advance'.format(self.url), json=u).json()['payload']
# Check results
points = self.get_all_points(self.url)
df = self.results_to_df(points, start_time, start_time+length, self.url)
ref_filepath = os.path.join(utilities.get_root_path(), 'testing', 'references', self.name, 'results_event_test.csv')
self.compare_ref_timeseries_df(df,ref_filepath)
class API(unittest.TestCase, utilities.partialTestAPI):
'''Tests the api for testcase.
Actual test methods implemented in utilities.partialTestAPI. Set self
attributes defined there for particular testcase in setUp method here.
'''
def setUp(self):
'''Setup for testcase.
'''
self.name = 'bestest_hydronic_heat_pump'
self.url = 'http:https://127.0.0.1:5000'
self.step_ref = 3600
self.test_time_period = 'peak_heat_day'
#<u_variable>_activate is meant to be 0 for the test_advance_false_overwrite API test
self.input = {'oveTSet_activate': 0, 'oveTSet_u': 273.15+22}
self.measurement = 'weaSta_reaWeaPAtm_y'
self.forecast_point = 'EmissionsElectricPower'
if __name__ == '__main__':
utilities.run_tests(os.path.basename(__file__))