@@ -55,7 +55,7 @@ def setup_class(cls):
5555 cls .seedKinetics = os .path .join (cls .databaseDirectory , "kinetics" , "libraries" , "testSeed" )
5656 cls .seedKineticsEdge = os .path .join (cls .databaseDirectory , "kinetics" , "libraries" , "testSeed_edge" )
5757
58- os .mkdir (os .path .join (cls .testDir , cls .outputDir ))
58+ os .makedirs (os .path .join (cls .testDir , cls .outputDir ), exist_ok = True )
5959
6060 cls .rmg = RMG (
6161 input_file = os .path .join (cls .testDir , "input.py" ),
@@ -174,7 +174,7 @@ def test_rmg_memory(self):
174174
175175 def test_make_cantera_input_file (self ):
176176 """
177- This tests to ensure that a usable Cantera input file is created.
177+ This test ensures that a usable Cantera input file is created.
178178 """
179179 import cantera as ct
180180
@@ -274,7 +274,7 @@ def setup_class(cls):
274274 cls .outputDir = os .path .join (cls .testDir , "output" )
275275 cls .databaseDirectory = settings ["database.directory" ]
276276
277- os .mkdir (os .path .join (cls .testDir , cls .outputDir ))
277+ os .makedirs (os .path .join (cls .testDir , cls .outputDir ), exist_ok = True )
278278
279279 cls .max_iter = 10
280280
@@ -360,168 +360,3 @@ def teardown_class(cls):
360360 os .remove (os .path .join (cls .test_dir , "RMG.profile.dot" ))
361361 os .remove (os .path .join (cls .test_dir , "RMG.profile.dot.ps2" ))
362362
363-
364- class TestCanteraOutput :
365- def setup_class (self ):
366- self .chemkin_files = {
367- """ELEMENTS
368- H
369- D /2.014/
370- T /3.016/
371- C
372- CI /13.003/
373- O
374- OI /18.000/
375- N
376-
377- END
378-
379- SPECIES
380- ethane(1)
381- CH3(4)
382- END
383-
384- THERM ALL
385- 300.000 1000.000 5000.000
386-
387- ethane(1) H 6 C 2 G100.000 5000.000 954.52 1
388- 4.58987205E+00 1.41507042E-02-4.75958084E-06 8.60284590E-10-6.21708569E-14 2
389- -1.27217823E+04-3.61762003E+00 3.78032308E+00-3.24248354E-03 5.52375224E-05 3
390- -6.38573917E-08 2.28633835E-11-1.16203404E+04 5.21037799E+00 4
391-
392- CH3(4) H 3 C 1 G100.000 5000.000 1337.62 1
393- 3.54144859E+00 4.76788187E-03-1.82149144E-06 3.28878182E-10-2.22546856E-14 2
394- 1.62239622E+04 1.66040083E+00 3.91546822E+00 1.84153688E-03 3.48743616E-06 3
395- -3.32749553E-09 8.49963443E-13 1.62856393E+04 3.51739246E-01 4
396-
397- END
398-
399-
400-
401- REACTIONS KCAL/MOLE MOLES
402-
403- CH3(4)+CH3(4)=ethane(1) 8.260e+17 -1.400 1.000
404-
405- END
406- """ : True ,
407- """ELEMENTS
408- CI /13.003/
409- O
410- OI /18.000/
411- N
412-
413- END
414-
415- SPECIES
416- ethane(1)
417- CH3(4)
418- END
419-
420- THERM ALL
421- 300.000 1000.000 5000.000
422-
423- ethane(1) H 6 C 2 G100.000 5000.000 954.52 1
424- 4.58987205E+00 1.41507042E-02-4.75958084E-06 8.60284590E-10-6.21708569E-14 2
425- -1.27217823E+04-3.61762003E+00 3.78032308E+00-3.24248354E-03 5.52375224E-05 3
426- -6.38573917E-08 2.28633835E-11-1.16203404E+04 5.21037799E+00 4
427-
428- CH3(4) H 3 C 1 G100.000 5000.000 1337.62 1
429- 3.54144859E+00 4.76788187E-03-1.82149144E-06 3.28878182E-10-2.22546856E-14 2
430- 1.62239622E+04 1.66040083E+00 3.91546822E+00 1.84153688E-03 3.48743616E-06 3
431- -3.32749553E-09 8.49963443E-13 1.62856393E+04 3.51739246E-01 4
432-
433- END
434-
435-
436-
437- REACTIONS KCAL/MOLE MOLES
438-
439- CH3(4)+CH3(4)=ethane(1) 8.260e+17 -1.400 1.000
440-
441- END
442- """ : False ,
443- """ELEMENTS
444- H
445- D /2.014/
446- T /3.016/
447- C
448- CI /13.003/
449- O
450- OI /18.000/
451- N
452-
453- END
454-
455- SPECIES
456- ethane(1)
457- CH3(4)
458- END
459-
460- THERM ALL
461- 300.000 1000.000 5000.000
462-
463- ethane(1) H 6 C 2 G100.000 5000.000 954.52 1
464- 4.58987205E+00 1.41507042E-02-4.75958084E-06 8.60284590E-10-6.21708569E-14 2
465- -1.27217823E+04-3.61762003E+00 3.78032308E+00-3.24248354E-03 5.52375224E-05 3
466- -6.38573917E-08 2.28633835E-11-1.16203404E+04 5.21037799E+00 4
467-
468- END
469-
470- REACTIONS KCAL/MOLE MOLES
471-
472- CH3(4)+CH3(4)=ethane(1) 8.260e+17 -1.400 1.000
473-
474- END
475- """ : False ,
476- }
477- self .rmg = RMG ()
478- self .dir_name = "temp_dir_for_testing"
479- self .rmg .output_directory = os .path .join (originalPath , ".." , "test" , "rmgpy" , "test_data" , self .dir_name )
480-
481- self .tran_dat = """
482- ! Species Shape LJ-depth LJ-diam DiplMom Polzblty RotRelaxNum Data
483- ! Name Index epsilon/k_B sigma mu alpha Zrot Source
484- ethane(1) 2 252.301 4.302 0.000 0.000 1.500 ! GRI-Mech
485- CH3(4) 2 144.001 3.800 0.000 0.000 0.000 ! GRI-Mech
486- """
487-
488- def teardown_class (self ):
489- os .chdir (originalPath )
490- # try to remove the tree. If testChemkinToCanteraConversion properly
491- # ran, the files should already be removed.
492- try :
493- shutil .rmtree (self .dir_name )
494- except OSError :
495- pass
496- # go back to the main RMG-Py directory
497- os .chdir (".." )
498-
499- def test_chemkin_to_cantera_conversion (self ):
500- """
501- Tests that good and bad chemkin files raise proper exceptions
502- """
503-
504- from cantera .ck2yaml import InputError
505-
506- for ck_input , works in self .chemkin_files .items ():
507- os .chdir (originalPath )
508- os .mkdir (self .dir_name )
509- os .chdir (self .dir_name )
510-
511- f = open ("chem001.inp" , "w" )
512- f .write (ck_input )
513- f .close ()
514-
515- f = open ("tran.dat" , "w" )
516- f .write (self .tran_dat )
517- f .close ()
518-
519- if works :
520- self .rmg .generate_cantera_files (os .path .join (os .getcwd (), "chem001.inp" ))
521- else :
522- with pytest .raises (InputError ):
523- self .rmg .generate_cantera_files (os .path .join (os .getcwd (), "chem001.inp" ))
524-
525- # clean up
526- os .chdir (originalPath )
527- shutil .rmtree (self .dir_name )
0 commit comments