Skip to content

Commit 08bbcac

Browse files
committed
missed several syntax changes, updated
1 parent 73dcb29 commit 08bbcac

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

rmgpy/rmg/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import numpy as np
4949
import psutil
5050
import yaml
51-
from cantera import ck2cti
51+
from cantera import ck2yaml
5252
from scipy.optimize import brute
5353

5454
import rmgpy.util as util
@@ -1088,14 +1088,14 @@ def execute(self, initialize=True, **kwargs):
10881088

10891089
self.run_model_analysis()
10901090

1091-
# generate Cantera files chem.cti & chem_annotated.cti in a designated `cantera` output folder
1091+
# generate Cantera files chem.yaml & chem_annotated.yaml in a designated `cantera` output folder
10921092
try:
10931093
if any([s.contains_surface_site() for s in self.reaction_model.core.species]):
10941094
self.generate_cantera_files(os.path.join(self.output_directory, 'chemkin', 'chem-gas.inp'),
1095-
surfaceFile=(
1095+
surface_file=(
10961096
os.path.join(self.output_directory, 'chemkin', 'chem-surface.inp')))
10971097
self.generate_cantera_files(os.path.join(self.output_directory, 'chemkin', 'chem_annotated-gas.inp'),
1098-
surfaceFile=(os.path.join(self.output_directory, 'chemkin',
1098+
surface_file=(os.path.join(self.output_directory, 'chemkin',
10991099
'chem_annotated-surface.inp')))
11001100
else: # gas phase only
11011101
self.generate_cantera_files(os.path.join(self.output_directory, 'chemkin', 'chem.inp'))
@@ -1660,13 +1660,13 @@ def process_reactions_to_species(self, obj):
16601660

16611661
def generate_cantera_files(self, chemkin_file, **kwargs):
16621662
"""
1663-
Convert a chemkin mechanism chem.inp file to a cantera mechanism file chem.cti
1663+
Convert a chemkin mechanism chem.inp file to a cantera mechanism file chem.yaml
16641664
and save it in the cantera directory
16651665
"""
16661666
transport_file = os.path.join(os.path.dirname(chemkin_file), 'tran.dat')
1667-
file_name = os.path.splitext(os.path.basename(chemkin_file))[0] + '.cti'
1667+
file_name = os.path.splitext(os.path.basename(chemkin_file))[0] + '.yaml'
16681668
out_name = os.path.join(self.output_directory, 'cantera', file_name)
1669-
if 'surfaceFile' in kwargs:
1669+
if 'surface_file' in kwargs:
16701670
out_name = out_name.replace('-gas.', '.')
16711671
cantera_dir = os.path.dirname(out_name)
16721672
try:
@@ -1676,14 +1676,14 @@ def generate_cantera_files(self, chemkin_file, **kwargs):
16761676
raise
16771677
if os.path.exists(out_name):
16781678
os.remove(out_name)
1679-
parser = ck2cti.Parser()
1679+
parser = ck2yaml.Parser()
16801680
try:
1681-
parser.convertMech(chemkin_file, transportFile=transport_file, outName=out_name, quiet=True, permissive=True,
1681+
parser.convert_mech(chemkin_file, transport_file=transport_file, out_name=out_name, quiet=True, permissive=True,
16821682
**kwargs)
1683-
except ck2cti.InputParseError:
1683+
except ck2yaml.InputError:
16841684
logging.exception("Error converting to Cantera format.")
16851685
logging.info("Trying again without transport data file.")
1686-
parser.convertMech(chemkin_file, outName=out_name, quiet=True, permissive=True, **kwargs)
1686+
parser.convert_mech(chemkin_file, out_name=out_name, quiet=True, permissive=True, **kwargs)
16871687

16881688
def initialize_reaction_threshold_and_react_flags(self):
16891689
num_core_species = len(self.reaction_model.core.species)

rmgpy/rmg/mainTest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_make_cantera_input_file(self):
180180
outName = os.path.join(self.rmg.output_directory, 'cantera')
181181
files = os.listdir(outName)
182182
for f in files:
183-
if '.cti' in f:
183+
if '.yaml' in f:
184184
try:
185185
ct.Solution(os.path.join(outName, f))
186186
except:
@@ -492,7 +492,7 @@ def test_chemkin_to_cantera_conversion(self):
492492
Tests that good and bad chemkin files raise proper exceptions
493493
"""
494494

495-
from cantera.ck2cti import InputParseError
495+
from cantera.ck2yaml import InputError
496496

497497
for ck_input, works in self.chemkin_files.items():
498498
os.chdir(originalPath)
@@ -510,7 +510,7 @@ def test_chemkin_to_cantera_conversion(self):
510510
if works:
511511
self.rmg.generate_cantera_files(os.path.join(os.getcwd(), 'chem001.inp'))
512512
else:
513-
with self.assertRaises(InputParseError):
513+
with self.assertRaises(InputError):
514514
self.rmg.generate_cantera_files(os.path.join(os.getcwd(), 'chem001.inp'))
515515

516516
# clean up

rmgpy/tools/canteramodel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def __init__(self, species_list=None, reaction_list=None, canteraFile='', output
203203
`species_list`: list of RMG species objects
204204
`reaction_list`: list of RMG reaction objects
205205
`reaction_map`: dict mapping the RMG reaction index within the `reaction_list` to cantera model reaction(s) indices
206-
`canteraFile` path of the chem.cti file associated with this job
206+
`canteraFile` path of the chem.yaml file associated with this job
207207
`conditions`: a list of `CanteraCondition` objects
208208
`sensitive_species`: a list of RMG species objects for conductng sensitivity analysis on
209209
`thermo_SA`: a boolean indicating whether or not to run thermo SA. By default, if sensitive_species is given,
@@ -289,19 +289,19 @@ def refresh_model(self):
289289

290290
def load_chemkin_model(self, chemkin_file, transport_file=None, **kwargs):
291291
"""
292-
Convert a chemkin mechanism chem.inp file to a cantera mechanism file chem.cti
292+
Convert a chemkin mechanism chem.inp file to a cantera mechanism file chem.yaml
293293
and save it in the output_directory
294294
Then load it into self.model
295295
"""
296-
from cantera import ck2cti
296+
from cantera import ck2yaml
297297

298298
base = os.path.basename(chemkin_file)
299299
base_name = os.path.splitext(base)[0]
300-
out_name = os.path.join(self.output_directory, base_name + ".cti")
300+
out_name = os.path.join(self.output_directory, base_name + ".yaml")
301301
if os.path.exists(out_name):
302302
os.remove(out_name)
303-
parser = ck2cti.Parser()
304-
parser.convertMech(chemkin_file, transportFile=transport_file, outName=out_name, **kwargs)
303+
parser = ck2yaml.Parser()
304+
parser.convert_mech(chemkin_file, transport_file=transport_file, out_name=out_name, **kwargs)
305305
self.model = ct.Solution(out_name)
306306

307307
def modify_reaction_kinetics(self, rmg_reaction_index, rmg_reaction):

0 commit comments

Comments
 (0)