forked from CURENT/andes
/
benchmarks.py
97 lines (74 loc) 路 2.02 KB
/
benchmarks.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
# Write the benchmarking functions here.
# See "Writing benchmarks" in the asv docs for more information.
import os
import andes
import andes.io
def base_path():
path, _ = os.path.split(__file__)
return os.path.join(path, '../../andes/cases/')
def load_system(case_path):
"""
Load a test case and return an ``andes.system.System`` object.
"""
ss = andes.system.System(case_path)
ss.undill()
andes.io.parse(ss)
ss.setup()
ss.files.no_output = True
ss.TDS.config.tol = 1e-6
return ss
def prep():
"""
Generate numerical code.
"""
ss = andes.System()
try:
try:
try:
ss.prepare(incremental=True)
return
except TypeError:
pass
ss.prepare(incremental=True, quick=True)
return
except TypeError:
pass
ss.prepare(quick=True)
return
except TypeError:
pass
ss.prepare()
class TimeCodeGen:
def setup(self):
prep()
def time_codegen(self):
"""
Empty function to invoke its setup.
"""
pass
class TimePFlow:
def setup(self):
case = "kundur/kundur_full.xlsx"
self.ss = load_system(os.path.join(base_path(), case))
def time_kundur_power_flow(self):
self.ss.PFlow.run()
class TimePFlowMPC:
def setup(self):
case = "../../../matpower/data/case9241pegase.m"
self.ss = load_system(os.path.join(base_path(), case))
def time_9241_power_flow(self):
self.ss.PFlow.run()
class TimeTDS:
def setup(self):
case = "kundur/kundur_full.xlsx"
self.ss = load_system(os.path.join(base_path(), case))
self.ss.PFlow.run()
def time_kundur_time_domain(self):
self.ss.TDS.run()
class TimeTDSAW:
def setup(self):
case = "kundur/kundur_aw.xlsx"
self.ss = load_system(os.path.join(base_path(), case))
self.ss.PFlow.run()
def time_kundur_time_domain_aw(self):
self.ss.TDS.run()