-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
better species naming for cantera models #1065
Comments
I'm not familiar with the naming convention on Cantera; if it's really that flexible, this could be a nice feature. |
Added an option to 'toCantera' methods in Species and Reaction to allow for the name of the species/reaction to be the RMG name instead of the chemkin name. The default behavior is still the same. This is one step in addressing issue #1065.
I wrote up this notebook which provides the species, thermo and reaction blocks to input into a cti file so analysis can be conducted in cantera with SMILES as the species names. This is kind of a first step to getting better naming for the species in cantera modules. |
Added an option to 'toCantera' methods in Species and Reaction to allow for the name of the species/reaction to be the RMG name instead of the chemkin name. The default behavior is still the same. This is one step in addressing issue #1065.
Added an option to 'toCantera' methods in Species and Reaction to allow for the name of the species/reaction to be the RMG name instead of the chemkin name. The default behavior is still the same. This is one step in addressing issue #1065.
I found a way to rename species from an RMG run and place them into a cantera input file. I also commonly use this method, which renames all species based on SMILES and ensures they don't overlap. This requires the def make_string_labels_independent(species):
"""
This method reads in species labels and makes sure none of them conflict
If a conflict occurs, the second occurance will have '-2' added
"""
labels = set()
for spec in species:
duplicate_index = 1
potential_label = spec.label
while potential_label in labels:
duplicate_index += 1
potential_label = spec.label + '-{}'.format(duplicate_index)
spec.label = potential_label
labels.add(potential_label)
# use the method
species, reactions = loadChemkinFile(chemkinPath, speciesDictPath, readComments = False, useChemkinNames=False)
make_string_labels_independent(species)
#convert to cantera objects
ct_species = [spec.toCantera(useChemkinIdentifier = False) for spec in species]
# since this can return a rxn or list of reactions, this allows to make a list based on the returned type
ct_reactions = []
for rxn in reactions:
ct_rxn = rxn.toCantera(useChemkinIdentifier = False)
if isinstance(ct_rxn, list):
ct_reactions.extend(ct_rxn)
else:
ct_reactions.append(ct_rxn)
gas = ct.Solution(thermo='IdealGas', kinetics='GasKinetics',
species=ct_species, reactions=ct_reactions)
# make cantera input file
new_file = soln2cti.write(gas)
# move the file to new location
os.rename(new_file, os.path.join(mainPath,'cantera_new_names.cti')) |
should this issue be closed @goldmanm? |
This issue is no longer relevant - we have switched to Cantera 2.6 in #2288 and this function is gone. Closing as stale. |
To the best of my knowledge, cantera does not have the restrictive species naming guidelines that chemkin has. When generating a cantera model, we can apply more descriptive names (like their SMILES) than would be possible with chemkin.
We currently create the cantera input file by converting from the chemkin input file with
ck2cti
. Getting better naming would require generating the input file directly from RMG.@alongd, you wrote the cantera conversion for RMG, do you have thoughts on this?
The text was updated successfully, but these errors were encountered: