I am trying to extract some skeletal mechanism from available detailed mechanism. Here you can see extracting sub-mechanism from GRI3.0 mechanism. Is there any way to export the submechanism in CANTERA. More specifically can I somehow export gas2 in following example to a .cti or .xml file?
from cantera import *
import numpy as np
reaction_mech = 'gri30.cti'
all_species = Species.listFromFile(reaction_mech)
species = []
# Filter species
for S in all_species:
comp = S.composition
if 'C' in comp and comp.get('C') >= 2:
# Exclude all C compounds with more than 2 C atoms
continue
species.append(S)
species_names = {S.name for S in species}
print('Species: {0}'.format(', '.join(S.name for S in species)))
all_reactions = Reaction.listFromFile(reaction_mech)
reactions = []
for R in all_reactions:
if not all(reactant in species_names for reactant in R.reactants):
continue
if not all(product in species_names for product in R.products):
continue
reactions.append(R)
gas1 = Solution('gri30.xml')
gas2 = Solution(thermo='IdealGas', kinetics='GasKinetics',
species=species, reactions=reactions)