Skip to content

Commit 4bb147e

Browse files
committed
Tests: main
1 parent 1017277 commit 4bb147e

1 file changed

Lines changed: 42 additions & 27 deletions

File tree

tests/test_main.py

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
'adapter': 'CanteraConstantTP',
5757
'atol': 1e-06,
5858
'global_observables': None,
59+
'max_sa_workers': 24,
5960
'pdep_SA_threshold': 0.001,
6061
'rtol': 0.0001,
6162
'P_list': None,
@@ -109,6 +110,7 @@
109110
'T': 1000.0,
110111
'V': None,
111112
'conditions_per_iteration': 12,
113+
'idt_mode': 'matrix',
112114
'termination_conversion': {'H2': 0.9},
113115
'termination_rate_ratio': None,
114116
'termination_time': (5.0, 's'),
@@ -127,6 +129,10 @@
127129
'xyz': None,
128130
'seed_all_rads': None,
129131
'solvent': False,
132+
'role': None,
133+
'equivalence_ratios': None,
134+
'oxidizer_fraction': None,
135+
'diluent_to_oxidizer_ratio': None,
130136
},
131137
{'SA_observable': False,
132138
'UA_observable': False,
@@ -142,6 +148,10 @@
142148
'xyz': None,
143149
'seed_all_rads': None,
144150
'solvent': False,
151+
'role': None,
152+
'equivalence_ratios': None,
153+
'oxidizer_fraction': None,
154+
'diluent_to_oxidizer_ratio': None,
145155
},
146156
{'SA_observable': True,
147157
'UA_observable': False,
@@ -157,6 +167,10 @@
157167
'xyz': None,
158168
'seed_all_rads': None,
159169
'solvent': False,
170+
'role': None,
171+
'equivalence_ratios': None,
172+
'oxidizer_fraction': None,
173+
'diluent_to_oxidizer_ratio': None,
160174
},
161175
{'SA_observable': True,
162176
'UA_observable': False,
@@ -172,7 +186,11 @@
172186
'xyz': None,
173187
'seed_all_rads': None,
174188
'solvent': False,
175-
},],
189+
'role': None,
190+
'equivalence_ratios': None,
191+
'oxidizer_fraction': None,
192+
'diluent_to_oxidizer_ratio': None,
193+
}],
176194
'species_constraints': None,
177195
}
178196
rmg_minimal_defaults = rmg_minimal.copy()
@@ -296,9 +314,13 @@ def test_set_paths():
296314
'RMG log': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/RMG/RMG.log',
297315
'RMG job log': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/RMG/job.log',
298316
'RMS': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/RMG/rms',
317+
'figs': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/Figures',
299318
'SA': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA',
300319
'SA input': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA/input.py',
301320
'SA coefficients': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA/sa_coefficients.yml',
321+
'SA dict': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA/sa.yaml',
322+
'SA IDT dict': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA/sa_idt.yaml',
323+
'SA IDT dict top X': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA/sa_idt_top_x.yaml',
302324
'SA solver': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/SA/solver',
303325
'cantera annotated': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/RMG/cantera/chem_annotated.yaml',
304326
'chem annotated': 'T3/Projects/test_minimal_delete_after_usage/iteration_1/RMG/chemkin/chem_annotated.inp',
@@ -327,82 +349,75 @@ def test_restart():
327349
os.makedirs(empty_dir)
328350

329351
# empty project directory
330-
# results in iteration=0, run_rmg=True
352+
# results in iteration=0, run_rmg=True, restart_rmg=False
331353
t3 = T3(project='test_restart',
332354
project_directory=os.path.join(restart_base_path, 'r0'),
333355
t3=t3_minimal,
334356
rmg=rmg_minimal,
335357
qm=qm_minimal,
336358
)
337-
assert t3.restart() == (0, True)
359+
assert t3.restart() == (0, True, False)
338360

339361
# empty 'iteration_1' folder in project directory
340-
# results in iteration=1, run_rmg=True
362+
# results in iteration=1, run_rmg=True, restart_rmg=False
341363
t3 = T3(project='test_restart',
342364
project_directory=os.path.join(restart_base_path, 'r1'),
343365
t3=t3_minimal,
344366
rmg=rmg_minimal,
345367
qm=qm_minimal,
346368
)
347-
assert t3.restart() == (1, True)
369+
assert t3.restart() == (1, True, False)
348370

349371
# 'iteration_2' folder with an 'RMG.log' indicating a non-converged job
350-
# results in iteration=2, run_rmg=True
372+
# results in iteration=2, run_rmg=False, restart_rmg=True (RMG started but didn't terminate)
351373
t3 = T3(project='test_restart',
352374
project_directory=os.path.join(restart_base_path, 'r2'),
353375
t3=t3_minimal,
354376
rmg=rmg_minimal,
355377
qm=qm_minimal,
356378
)
357-
assert t3.restart() == (2, True)
379+
assert t3.restart() == (2, False, True)
358380

359381
# 'iteration_3' folder with an 'RMG.log' indicating a converged job
360-
# results in iteration=3, run_rmg=False
382+
# results in iteration=3, run_rmg=False, restart_rmg=False
361383
t3 = T3(project='test_restart',
362384
project_directory=os.path.join(restart_base_path, 'r3'),
363385
t3=t3_minimal,
364386
rmg=rmg_minimal,
365387
qm=qm_minimal,
366388
)
367-
assert t3.restart() == (3, False)
389+
assert t3.restart() == (3, False, False)
368390

369391
# 'iteration_4' folder with an 'RMG.log' indicating a converged job and an 'arc.log' indicating a non-converged job
370-
# results in iteration=4, run_rmg=False
392+
# results in iteration=4, run_rmg=False, restart_rmg=False
371393
t3 = T3(project='test_restart',
372394
project_directory=os.path.join(restart_base_path, 'r4'),
373395
t3=t3_minimal,
374396
rmg=rmg_minimal,
375397
qm=qm_minimal,
376398
)
377-
assert t3.restart() == (4, False)
399+
assert t3.restart() == (4, False, False)
378400

379401
# 'iteration_5' folder with an 'RMG.log' indicating a converged job and an 'arc.log' indicating a non-converged job
380-
# results in iteration=5, run_rmg=False
402+
# results in iteration=5, run_rmg=False, restart_rmg=False
381403
t3 = T3(project='test_restart',
382404
project_directory=os.path.join(restart_base_path, 'r5'),
383405
t3=t3_minimal,
384406
rmg=rmg_minimal,
385407
qm=qm_minimal,
386408
)
387-
assert t3.restart() == (5, False)
409+
assert t3.restart() == (5, False, False)
388410

389-
# 'iteration_6' folder with an 'RMG.log' indicating a converged job and an 'arc.log' indicating a non-converged job
390-
# and an ARC 'restart.yml' file
391-
# results in a complete ARC run, iteration=6+1=7, run_rmg=True
411+
# 'iteration_6' folder with an 'RMG.log' indicating a converged job, an 'arc.log' indicating
412+
# a converged ARC run, and an ARC 'restart.yml' file (left over from a previous interrupted run).
413+
# Because arc.log already contains the termination line, the state machine sees ARC as
414+
# terminated and returns (6, False, False); restart_arc is NOT triggered.
392415
t3 = T3(project='test_restart',
393416
project_directory=os.path.join(restart_base_path, 'r6'),
394417
t3=t3_minimal,
395418
rmg=rmg_minimal,
396419
qm=qm_minimal,
397420
)
398-
t3.species = {0: T3Species(label='Imipramine_1_peroxy',
399-
qm_label='Imipramine_1_peroxy_0',
400-
smiles='C',
401-
reasons=['reason'],
402-
t3_status=T3Status.CONVERGED if False else T3Status.PENDING, # logic check?
403-
t3_index=0,
404-
created_at_iteration=2)}
405-
# Correction: 'converged' was None in original test, so status PENDING.
406421
t3.species = {0: T3Species(label='Imipramine_1_peroxy',
407422
qm_label='Imipramine_1_peroxy_0',
408423
smiles='C',
@@ -411,7 +426,7 @@ def test_restart():
411426
t3_index=0,
412427
created_at_iteration=2)}
413428
t3.dump_species_and_reactions()
414-
assert t3.restart() == (7, True)
429+
assert t3.restart() == (6, False, False)
415430
t3.process_arc_run()
416431
assert t3.species[0].is_converged is True
417432
with open(os.path.join(restart_base_path, 'r6', 'iteration_6', 'ARC', 'arc.log'), 'r') as f:
@@ -427,7 +442,7 @@ def test_restart():
427442
rmg=rmg_minimal,
428443
qm=qm_minimal,
429444
)
430-
assert t3.restart() == (8, True)
445+
assert t3.restart() == (7, False, False)
431446

432447
# restore r6 log file
433448
with open(os.path.join(restart_base_path, 'r6', 'iteration_6', 'ARC', 'arc.log'), 'w') as f:
@@ -1104,7 +1119,7 @@ def test_dump_species():
11041119
t3.dump_species_and_reactions()
11051120
assert os.path.isfile(os.path.join(dump_species_path, 't3.log'))
11061121
assert os.path.isfile(os.path.join(dump_species_path, 'species.yml'))
1107-
assert t3.restart() == (5, True)
1122+
assert t3.restart() == (5, True, False)
11081123

11091124

11101125
def test_load_species():

0 commit comments

Comments
 (0)