@@ -456,7 +456,7 @@ class TestWriteInputFile:
456456 'simpleReactor': simple_reactor, ✅
457457 'constantVIdealGasReactor' : constant_V_ideal_gas_reactor,
458458 'constantTPIdealGasReactor' : constant_TP_ideal_gas_reactor,
459- 'liquidSurfaceReactor' : liquid_cat_reactor,
459+ 'liquidSurfaceReactor' : liquid_cat_reactor,
460460 'constantTVLiquidReactor': constant_T_V_liquid_reactor,
461461 'liquidReactor': liquid_reactor,
462462 'surfaceReactor': surface_reactor, ✅
@@ -468,7 +468,6 @@ def setup_method(self):
468468 global rmg
469469 rmg .reaction_systems = []
470470
471-
472471 def test_write_superminimal_input (self ):
473472 """
474473 Test that we can write superminimal input file and read it back in with the same values.
@@ -477,7 +476,6 @@ def test_write_superminimal_input(self):
477476 superminimal_input_file = '../../../examples/rmg/superminimal/input.py'
478477 superminimal_output_file = 'temp_superminimal_input.py'
479478
480-
481479 rmg = RMG ()
482480 inp .read_input_file (superminimal_input_file , rmg )
483481
@@ -492,16 +490,14 @@ def test_write_superminimal_input(self):
492490 termination_conversion = term .conversion
493491 termination_converstion_species = term .species .label
494492
495-
496-
497493 inp .save_input_file (superminimal_output_file , rmg )
498494 # read it back in and confirm all the values match
499495 rmg1 = RMG ()
500496 inp .read_input_file (superminimal_output_file , rmg1 )
501497 assert rmg1 .reaction_systems [0 ].T .value_si == T
502498 assert rmg1 .reaction_systems [0 ].P .value_si == P
503499 output_mol_fractions = {k .label : v for k , v in rmg1 .reaction_systems [0 ].initial_mole_fractions .items ()}
504- assert output_mol_fractions == initialMoleFractions
500+ assert output_mol_fractions == initialMoleFractions
505501 for term in rmg1 .reaction_systems [0 ].termination :
506502 if hasattr (term , 'time' ):
507503 assert term .time .value_si == termination_time
@@ -521,12 +517,10 @@ def test_write_superminimal_and_run(self):
521517 import os
522518 import shutil
523519
524-
525520 superminimal_input_file = '../../../examples/rmg/superminimal/input.py'
526521 new_run_dir = 'temp_superminimal_run'
527522 os .makedirs (new_run_dir , exist_ok = True )
528523 superminimal_output_file = os .path .join (new_run_dir , 'temp_superminimal_input.py' )
529-
530524
531525 rmg = RMG ()
532526 inp .read_input_file (superminimal_input_file , rmg )
@@ -536,11 +530,9 @@ def test_write_superminimal_and_run(self):
536530 import subprocess
537531 subprocess .run (['python' , '../../../rmg.py' , superminimal_output_file ], check = True )
538532
539-
540533 # clean up
541534 shutil .rmtree (new_run_dir )
542535
543-
544536 def test_write_min_surf_input (self ):
545537 """
546538 Test that we can write the minimal surface input file and read it back in with the same values.
@@ -549,7 +541,6 @@ def test_write_min_surf_input(self):
549541 min_surf_input_file = '../../../examples/rmg/minimal_surface/input.py'
550542 min_surf_output_file = 'temp_min_surf_input.py'
551543
552-
553544 rmg = RMG ()
554545 inp .read_input_file (min_surf_input_file , rmg )
555546
@@ -570,15 +561,14 @@ def test_write_min_surf_input(self):
570561 binding_energies = {k : v .value_si for k , v in rmg .binding_energies .items ()}
571562 surface_site_density = rmg .surface_site_density .value_si
572563
573-
574564 inp .save_input_file (min_surf_output_file , rmg )
575565 # read it back in and confirm all the values match
576566 rmg1 = RMG ()
577567 inp .read_input_file (min_surf_output_file , rmg1 )
578568 assert rmg1 .reaction_systems [0 ].T .value_si == T
579569 assert rmg1 .reaction_systems [0 ].P_initial .value_si == P
580570 output_mol_fractions = {k .label : v for k , v in rmg1 .reaction_systems [0 ].initial_gas_mole_fractions .items ()}
581- assert output_mol_fractions == initialMoleFractions
571+ assert output_mol_fractions == initialMoleFractions
582572 output_surface_coverages = {k .label : v for k , v in rmg1 .reaction_systems [0 ].initial_surface_coverages .items ()}
583573 assert output_surface_coverages == initialSurfaceCoverages
584574
@@ -600,3 +590,90 @@ def test_write_min_surf_input(self):
600590 import os
601591 os .remove (min_surf_output_file )
602592
593+ @pytest .mark .skip (reason = "Slow test that runs a full RMG job" )
594+ def test_write_min_surf_and_run (self ):
595+ """
596+ Test that we can write minimal surface input file and then run RMG without errors
597+ """
598+ import os
599+ import shutil
600+
601+ min_surf_input_file = '../../../examples/rmg/minimal_surface/input.py'
602+ new_run_dir = 'temp_min_surf_run'
603+ os .makedirs (new_run_dir , exist_ok = True )
604+ min_surf_output_file = os .path .join (new_run_dir , 'temp_min_surf_input.py' )
605+
606+ rmg = RMG ()
607+ inp .read_input_file (min_surf_input_file , rmg )
608+ inp .save_input_file (min_surf_output_file , rmg )
609+
610+ # run RMG with the new input file
611+ import subprocess
612+ subprocess .run (['python' , '../../../rmg.py' , min_surf_output_file ], check = True )
613+
614+ # clean up
615+ shutil .rmtree (new_run_dir )
616+
617+ @pytest .mark .skip (reason = "Slow because it has to compile Julia" )
618+ def test_write_liquid_cat_input (self ):
619+ """
620+ Test that we can write liquid catalyst input file and read it back in with the same values.
621+ """
622+
623+ liquid_cat_input_file = '../../../examples/rmg/liquid_cat/input.py'
624+ liquid_cat_output_file = 'temp_liquid_cat_input.py'
625+
626+ rmg = RMG ()
627+ inp .read_input_file (liquid_cat_input_file , rmg )
628+
629+ # read a bunch of values in from input file to check they are the same after writing
630+ T = rmg .reaction_systems [0 ].T .value_si
631+ tf = rmg .reaction_systems [0 ].tf
632+ liquid_init_conditions = {k : v for k , v in rmg .reaction_systems [0 ].initial_conditions ['liquid' ].items ()}
633+ surf_init_conditions = {k : v for k , v in rmg .reaction_systems [0 ].initial_conditions ['surface' ].items ()}
634+
635+ termination_species = rmg .reaction_systems [0 ].terminations [0 ][0 ].label
636+ termination_conversion = rmg .reaction_systems [0 ].terminations [0 ][1 ]
637+
638+ inp .save_input_file (liquid_cat_output_file , rmg )
639+ # read it back in and confirm all the values match
640+ rmg1 = RMG ()
641+ inp .read_input_file (liquid_cat_output_file , rmg1 )
642+ assert rmg1 .reaction_systems [0 ].T .value_si == T
643+ assert rmg1 .reaction_systems [0 ].tf == tf
644+
645+ liquid_init_conditions_output = {k : v for k , v in rmg1 .reaction_systems [0 ].initial_conditions ['liquid' ].items ()}
646+ assert pytest .approx (liquid_init_conditions_output ) == liquid_init_conditions
647+ surf_init_conditions_output = {k : v for k , v in rmg1 .reaction_systems [0 ].initial_conditions ['surface' ].items ()}
648+ assert pytest .approx (surf_init_conditions_output ) == surf_init_conditions
649+
650+ assert rmg1 .reaction_systems [0 ].terminations [0 ][0 ].label == termination_species
651+ assert rmg1 .reaction_systems [0 ].terminations [0 ][1 ] == termination_conversion
652+
653+ # clean up
654+ import os
655+ os .remove (liquid_cat_output_file )
656+
657+ @pytest .mark .skip (reason = "Slow test that runs a full RMG job" )
658+ def test_write_liquid_cat_and_run (self ):
659+ """
660+ Test that we can write liquid catalyst input file and then run RMG without errors
661+ """
662+ import os
663+ import shutil
664+
665+ liquid_cat_input_file = '../../../examples/rmg/liquid_cat/input.py'
666+ new_run_dir = 'temp_liquid_cat_run'
667+ os .makedirs (new_run_dir , exist_ok = True )
668+ liquid_cat_output_file = os .path .join (new_run_dir , 'temp_liquid_cat_input.py' )
669+
670+ rmg = RMG ()
671+ inp .read_input_file (liquid_cat_input_file , rmg )
672+ inp .save_input_file (liquid_cat_output_file , rmg )
673+
674+ # run RMG with the new input file
675+ import subprocess
676+ subprocess .run (['python' , '../../../rmg.py' , '-t' , '00:00:01:30' , liquid_cat_output_file ], check = True )
677+
678+ # clean up
679+ shutil .rmtree (new_run_dir )
0 commit comments