-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_tests.py
160 lines (139 loc) · 5.22 KB
/
run_tests.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
from asali.reactors.batch import BatchReactor
from asali.reactors.cstr import CstrReactor
from asali.reactors.het1d_steady_state import SteadyStateHeterogeneous1DReactor
from asali.reactors.het1d_transient import TransientHeterogeneous1DReactor
from asali.reactors.ph1d_steady_state import SteadyStatePseudoHomogeneous1DReactor
from asali.reactors.ph1d_transient import TransientPseudoHomogeneous1DReactor
from asali.utils.input_parser import InputParser
from tests.basic_unit_test import BasicUnitTest
from tests.reactor_unit_test import ReactorUnitTest
from asali.utils.unit_converter import UnitConverter
from asali.utils.cantera_file_converter import CanteraFileConverter
from termcolor import colored
import argparse
def unit_converter():
"""
Run unit test for UnitConverter
:return:
"""
uc = UnitConverter()
ut = BasicUnitTest(uc, "utils.json")
ut.check_all()
print(" ")
def cantera_file_converter():
"""
Run unit test for CanteraFileConverter
:return:
"""
cfc = CanteraFileConverter()
ut = BasicUnitTest(cfc, "utils.json")
ut.check_all()
print(" ")
def input_parser():
"""
Run unit test for InputParser
:return:
"""
ip = InputParser()
ut = BasicUnitTest(ip, "utils.json")
ut.check_all()
print(" ")
def batch_reactor(is_local):
"""
Run unit test for BatchReactor
:param is_local: Bool that shows if the test is performed locally or not
:return:
"""
br = BatchReactor('tests/H2-O2-Rh.yaml', 'gas', 'Rh_surface')
ut = ReactorUnitTest(br, "reactors.json", is_local)
ut.check_all()
print(" ")
def cstr_reactor(is_local):
"""
Run unit test for CstrReactor
:param is_local: Bool that shows if the test is performed locally or not
:return:
"""
cr = CstrReactor('tests/H2-O2-Rh.yaml', 'gas', 'Rh_surface')
ut = ReactorUnitTest(cr, "reactors.json", is_local)
ut.check_all()
print(" ")
def steady_state_pseudohomogeneous_reactor(is_local):
"""
Run unit test for SteadyStatePseudoHomogeneous1DReactor
:param is_local: Bool that shows if the test is performed locally or not
:return:
"""
pfr = SteadyStatePseudoHomogeneous1DReactor('tests/H2-O2-Rh.yaml', 'gas', 'Rh_surface')
ut = ReactorUnitTest(pfr, "reactors.json", is_local)
ut.check_all()
print(" ")
def transient_pseudohomogeneous_reactor(is_local):
"""
Run unit test for TransientPseudoHomogeneous1DReactor
:param is_local: Bool that shows if the test is performed locally or not
:return:
"""
pfr = TransientPseudoHomogeneous1DReactor('tests/H2-O2-Rh.yaml', 'gas', 'Rh_surface')
ut = ReactorUnitTest(pfr, "reactors.json", is_local)
ut.check_all()
print(" ")
def steady_state_heterogeneous_reactor(is_local):
"""
Run unit test for SteadyStateHeterogeneous1DReactor
:param is_local: Bool that shows if the test is performed locally or not
:return:
"""
pfr = SteadyStateHeterogeneous1DReactor('tests/H2-O2-Rh.yaml', 'gas', 'Rh_surface')
ut = ReactorUnitTest(pfr, "reactors.json", is_local)
ut.check_all()
print(" ")
def transient_heterogeneous_reactor(is_local):
"""
Run unit test for TransientHeterogeneous1DReactor
:param is_local: Bool that shows if the test is performed locally or not
:return:
"""
pfr = TransientHeterogeneous1DReactor('tests/H2-O2-Rh.yaml', 'gas', 'Rh_surface')
ut = ReactorUnitTest(pfr, "reactors.json", is_local)
ut.check_all()
print(" ")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='')
parser.add_argument('--class', dest='class_to_check', help='Class to be check')
parser.add_argument('--local', action='store_true', dest='is_local', help='Is the test performed locally')
args = parser.parse_args()
if args.class_to_check is None:
class_to_check = "all"
else:
class_to_check = args.class_to_check.lower()
if class_to_check == "all":
input_parser()
unit_converter()
cantera_file_converter()
batch_reactor(args.is_local)
cstr_reactor(args.is_local)
steady_state_pseudohomogeneous_reactor(args.is_local)
transient_pseudohomogeneous_reactor(args.is_local)
steady_state_heterogeneous_reactor(args.is_local)
transient_heterogeneous_reactor(args.is_local)
elif class_to_check == "unitconverter":
unit_converter()
elif class_to_check == "batchreactor":
batch_reactor(args.is_local)
elif class_to_check == "cstrreactor":
cstr_reactor(args.is_local)
elif class_to_check == "steadystatepseudohomogeneous1dreactor":
steady_state_pseudohomogeneous_reactor(args.is_local)
elif class_to_check == "transientpseudohomogeneous1dreactor":
transient_pseudohomogeneous_reactor(args.is_local)
elif class_to_check == "steadystateheterogeneous1dreactor":
steady_state_heterogeneous_reactor(args.is_local)
elif class_to_check == "transientheterogeneous1dreactor":
transient_heterogeneous_reactor(args.is_local)
elif class_to_check == "canterafileconverter":
cantera_file_converter()
elif class_to_check == "inputparser":
input_parser()
else:
print(colored("ASALI::ERROR::UNKNOWN CLASS", "red"))