-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample_simulate.py
70 lines (58 loc) · 1.6 KB
/
example_simulate.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
from simapi import SimApi
from sim_timer import SimTimer
model_name = "test123"
model_count = 1
# TODO change to steps per hour parse on backend
step_size = 900 # in seconds
# TODO convert to dict {'days': , 'months': , 'year': } parse on backend
final_time = 24 # in hours
idf_path = "data_files/new.idf"
epw_path = "data_files/new.epw"
csv = ["data_files/new1.csv"]
timer = SimTimer()
sim = SimApi(
model_name=model_name,
model_count=model_count,
step_size=step_size,
final_time=final_time,
idf_path=idf_path,
epw_path=epw_path,
csv=csv
)
if not sim.login() == 200:
sim.create_user()
sim.login()
print("Generating FMU...")
timer.capture_start_time()
generate_resp = sim.send_and_generate()
print("Generate response: {}".format(generate_resp))
timer.capture_end_time()
timer.calc_runtime("gen_fmu")
if generate_resp == 201:
print("Initializing...")
timer.capture_start_time()
init_resp = sim.send_and_init()
timer.capture_end_time()
timer.calc_runtime("init_fmu")
else:
print("Something went wrong while generating the fmu!")
print(generate_resp)
exit(-1)
if init_resp == 200:
print("Simulating...")
timer.capture_start_time()
simulate_resp = sim.simulate_models()
timer.capture_end_time()
timer.calc_runtime("sim_fmu")
else:
print("Something went wrong while initializing the fmu!")
print(init_resp)
exit(-1)
timer.capture_start_time()
for name in sim.sim_names:
print("Sim name: {}".format(name))
sim.request_model_outputs(name)
print()
timer.capture_end_time()
timer.calc_runtime("req_outs")
timer.write_times()