Skip to content

Commit 2351724

Browse files
committed
Tests: Updated functional tests
1 parent d85b1d4 commit 2351724

File tree

2 files changed

+49
-31
lines changed

2 files changed

+49
-31
lines changed

functional/functional_test.py

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from arc import ARC
1313
from arc.common import ARC_PATH
14-
from arc.exceptions import InputError
1514
from arc.imports import settings
1615
from arc.reaction import ARCReaction
1716
from arc.species import ARCSpecies
@@ -50,6 +49,7 @@ def setUpClass(cls):
5049
job_types=cls.job_types,
5150
conformer_level='gfn2',
5251
level_of_theory='gfn2',
52+
arkane_level_of_theory='cbs-qb3',
5353
freq_scale_factor=1.0,
5454
n_confs=2,
5555
bac_type=None,
@@ -69,6 +69,7 @@ def setUpClass(cls):
6969
conformer_level='gfn2',
7070
level_of_theory='gfn2',
7171
ts_guess_level='gfn2',
72+
arkane_level_of_theory='cbs-qb3',
7273
freq_scale_factor=1.0,
7374
n_confs=2,
7475
dont_gen_confs=["TS0"],
@@ -77,38 +78,51 @@ def setUpClass(cls):
7778
compare_to_rmg=False,
7879
)
7980

80-
def testThermo(self):
81+
def test_thermo(self):
8182
"""Test thermo"""
8283
self.arc_object_1.execute()
8384
summary = self.arc_object_1.summary()
8485
for _, ter in summary.items():
8586
self.assertTrue(ter)
86-
self.assertTrue(os.path.exists(os.path.join(ARC_PATH, "functional", "test", "thermo", "output", "RMG libraries", "thermo")))
87-
with open(file=os.path.join(ARC_PATH, "functional", "test", "thermo", "output", "RMG libraries", "thermo", "FunctionalThermoTest.py"), mode='r') as f:
88-
entry = 0
87+
self.assertTrue(os.path.isfile(os.path.join(ARC_PATH, "functional", "test", "thermo", "calcs", "statmech", "thermo", "arkane.log")))
88+
species, thermo = 0, 0
89+
with open(file=os.path.join(ARC_PATH, "functional", "test", "thermo", "calcs", "statmech", "thermo", "input.py"), mode='r') as f:
8990
for line in f.readlines():
90-
if "entry" in line:
91-
entry += 1
92-
self.assertEqual(entry, len(self.species_list_1))
91+
if "species('" in line:
92+
species += 1
93+
if "thermo('" in line:
94+
thermo += 1
95+
self.assertEqual(species, len(self.species_list_1))
96+
self.assertEqual(thermo, len(self.species_list_1))
9397

94-
def testKinetic(self):
98+
def test_kinetic(self):
9599
"""Test kinetics"""
96-
try:
97-
self.arc_object_2.execute()
98-
except InputError as e:
99-
self.skipTest(f"execution of ARC failed: {e}, skipping this test for now...")
100+
self.arc_object_2.execute()
100101
summary = self.arc_object_2.summary()
101102
for _, ter in summary.items():
102103
self.assertTrue(ter)
103-
self.assertTrue(os.path.exists(os.path.join(ARC_PATH, "functional", "test", "kinetic", "output", "RMG libraries", "kinetics")))
104-
has_content = False
105-
with open(file=os.path.join(ARC_PATH, "functional", "test", "kinetic", "output", "RMG libraries", "kinetics", "reactions.py"), mode='r') as f:
104+
base_path = os.path.join(ARC_PATH, "functional", "test", "kinetic", "calcs", "statmech")
105+
self.assertTrue(os.path.isfile(os.path.join(base_path, "thermo", "input.py")))
106+
self.assertTrue(os.path.isfile(os.path.join(base_path, "kinetics", "input.py")))
107+
self.assertTrue(os.path.isfile(os.path.join(base_path, "kinetics", "species", "iC3H7.py")))
108+
self.assertTrue(os.path.isfile(os.path.join(base_path, "kinetics", "species", "nC3H7.py")))
109+
self.assertTrue(os.path.isfile(os.path.join(base_path, "kinetics", "TSs", "TS0.py")))
110+
species, thermo, kinetics, ts = 0, 0, 0, 0
111+
with open(file=os.path.join(base_path, "kinetics", "input.py"), mode='r') as f:
106112
for line in f.readlines():
107-
if "Arrhenius" in line:
108-
has_content = True
109-
break
110-
self.assertTrue(has_content)
111-
113+
if "species('" in line:
114+
species += 1
115+
elif "thermo('" in line:
116+
thermo += 1
117+
elif "kinetics(label='" in line:
118+
kinetics += 1
119+
elif "transitionState" in line:
120+
ts += 1
121+
self.assertEqual(species, 2)
122+
self.assertEqual(thermo, 0)
123+
self.assertEqual(kinetics, 1)
124+
self.assertEqual(ts, 2)
125+
112126
@classmethod
113127
def tearDownClass(cls):
114128
"""

functional/restart_test.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_restart_thermo(self):
8585
spc = True
8686
elif 'All jobs for species N2H3 successfully converged. Run time' in line:
8787
rtm = True
88-
elif 'Thermodynamics for H2O2' in line:
88+
elif ' H2O2 -135.82 239.05' in line:
8989
therm = True
9090
elif 'Sources of thermodynamic properties determined by RMG for the parity plots:' in line:
9191
src = True
@@ -108,15 +108,21 @@ def test_restart_thermo(self):
108108
'Conformers optimized and compared at b3lyp/6-31g(d,p) empiricaldispersion=gd3bj; ')
109109
self.assertTrue(status['CH3CO2_rad']['job_types']['sp'])
110110

111-
with open(os.path.join(project_directory, 'output', 'Species', 'H2O2', 'arkane', 'species_dictionary.txt'),
112-
'r') as f:
111+
with open(os.path.join(project_directory, 'output', 'RMG libraries', 'thermo', 'species_dictionary.txt'), 'r') as f:
113112
lines = f.readlines()
114-
adj_list = ''
113+
species_name = 'H2O2'
114+
adj_lines = list()
115+
found = False
115116
for line in lines:
116-
if 'H2O2' not in line:
117-
adj_list += line
118-
if line == '\n':
117+
text = line.strip()
118+
if not found:
119+
if text == species_name:
120+
found = True
121+
continue
122+
if text == '':
119123
break
124+
adj_lines.append(line)
125+
adj_list = ''.join(adj_lines)
120126
mol1 = Molecule().from_adjacency_list(adj_list)
121127
self.assertEqual(mol1.to_smiles(), 'OO')
122128

@@ -135,7 +141,7 @@ def test_restart_rate_1(self):
135141
with open(kinetics_library_path, 'r') as f:
136142
got_rate = False
137143
for line in f.readlines():
138-
if "kinetics = Arrhenius(A=(6.37e-02, '(cm^3/(mol*s))'), n=4.08, Ea=(57.55, 'kJ/mol')," in line:
144+
if "kinetics = Arrhenius(A=(6.37e-02, 'cm^3/(mol*s)'), n=4.08, Ea=(57.55, 'kJ/mol')," in line:
139145
got_rate = True
140146
break
141147
self.assertTrue(got_rate)
@@ -179,8 +185,6 @@ def test_restart_bde(self):
179185
lines = f.readlines()
180186
self.assertIn(' BDE report for anilino_radical:\n', lines)
181187
self.assertIn(' (1, 9) N - H 353.92\n', lines)
182-
self.assertIn(' (3, 4) C - H 454.12\n', lines)
183-
self.assertIn(' (5, 10) C - H 461.75\n', lines)
184188

185189
def test_globalize_paths(self):
186190
"""Test modifying a YAML file's contents to correct absolute file paths"""

0 commit comments

Comments
 (0)