Skip to content

Commit fe9e0b1

Browse files
committed
Testing conversion to Cantera for adsorbed species and reactions.
This is in the canteramodelTest. We load a gas/surface mechanism saved in chemkin format (updated in prior commit) into both RMG and into Cantera. We then convert the RMG objects into Cantera objects and then compare them all - species and reactions. This mirrors the way the gas phase parts were tested. Hopefully increases test coverage of the new to_cantera_kinetics methods.
1 parent 15ce6d5 commit fe9e0b1

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

test/rmgpy/tools/canteramodelTest.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,27 @@ def setup_class(self):
104104
self.ctSpecies = job.model.species()
105105
self.ctReactions = job.model.reactions()
106106

107+
# Now load surface species and kinetics
108+
folder = os.path.join(os.path.dirname(os.path.dirname(__file__)), "test_data", "chemkin", "chemkin_py")
109+
chemkin_path = os.path.join(folder, "surface", "chem-gas.inp")
110+
chemkin_surface_path = os.path.join(folder, "surface", "chem-surface.inp")
111+
dictionary_path = os.path.join(folder, "surface", "species_dictionary.txt")
112+
species, reactions = load_chemkin_file(chemkin_surface_path, dictionary_path)
113+
self.rmg_surface_ct_species = [spec.to_cantera(use_chemkin_identifier=True) for spec in species]
114+
self.rmg_surface_ct_reactions = []
115+
for rxn in reactions:
116+
converted_reactions = rxn.to_cantera(species, use_chemkin_identifier=True)
117+
if isinstance(converted_reactions, list):
118+
self.rmg_surface_ct_reactions.extend(converted_reactions)
119+
else:
120+
self.rmg_surface_ct_reactions.append(converted_reactions)
121+
job = Cantera()
122+
job.surface = True
123+
job.load_chemkin_model(chemkin_path, surface_file=chemkin_surface_path, quiet=True)
124+
self.ct_surface_species = job.surface.species()
125+
self.ct_surface_reactions = job.surface.reactions()
126+
127+
107128
def test_species_conversion(self):
108129
"""
109130
Test that species objects convert properly
@@ -115,9 +136,31 @@ def test_species_conversion(self):
115136

116137
def test_reaction_conversion(self):
117138
"""
118-
Test that species objects convert properly
139+
Test that reaction objects convert properly
119140
"""
120141
from rmgpy.tools.canteramodel import check_equivalent_cantera_reaction
121142

122143
for i in range(len(self.ctReactions)):
123144
assert check_equivalent_cantera_reaction(self.ctReactions[i], self.rmg_ctReactions[i])
145+
146+
def test_surface_species_conversion(self):
147+
"""
148+
Test that surface species objects convert properly
149+
"""
150+
from rmgpy.tools.canteramodel import check_equivalent_cantera_species
151+
152+
for i in range(len(self.ct_surface_species)):
153+
#print("Chemkin-to-Cantera:", self.ct_surfaceSpecies[i].input_data)
154+
#print("Chemkin-to-RMG-to-Cantera:", self.rmg_surface_ctSpecies[i].input_data)
155+
assert check_equivalent_cantera_species(self.ct_surface_species[i], self.rmg_surface_ct_species[i])
156+
157+
def test_surface_reaction_conversion(self):
158+
"""
159+
Test that surface reaction objects convert properly
160+
"""
161+
from rmgpy.tools.canteramodel import check_equivalent_cantera_reaction
162+
163+
for i in range(len(self.ct_surface_reactions)):
164+
#print("Chemkin-to-Cantera:", self.ct_surfaceReactions[i].input_data)
165+
#print("Chemkin-to-RMG-to-Cantera:", self.rmg_surface_ctReactions[i].input_data)
166+
assert check_equivalent_cantera_reaction(self.ct_surface_reactions[i], self.rmg_surface_ct_reactions[i])

0 commit comments

Comments
 (0)