-
Notifications
You must be signed in to change notification settings - Fork 228
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
Add and improve to_cantera methods for conversion to in-memory Cantera objects #2700
base: main
Are you sure you want to change the base?
Conversation
This took me a while to figure out what was happening. So I changed variable name, removed a redundant if block, and added a couple of comments.
It was fragile, depending on the precise ordering of lines in the test file.
To enable proper conversion in Cantera (for a future test) we need some gas phase parts to the chemkin mechanism. I added two extra types of surface reaction, an adsorption sticking coefficient, and an associative desorption. I also tidied up the species names and formatting.
to_cantera for Reaction and Species and some surface kinetics types squashed commit from Richard: Should be able to use the to_cantera_kinetics methods. Not sure about all these nested elifs. I think some are confused. Co-authored-by: Nora Khalil <khalil.nor@northeastern.edu> Co-authored-by: Richard West <r.west@northeastern.edu>
Nick add cm^5/(mol^2*s) dimensionality Co-authored-by: Sevy Harris <harris.se@northeastern.edu> Co-authored-by: Nicholas Tietje <tietje.n@northeastern.edu>
Cantera now has a BlowersMasel kinetics class. This requires Cantera > 2.6 As described in https://cantera.org/dev/python/kinetics.html#cantera.BlowersMaselRate the API may change suddenly on some versions.
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.
Regression Testing ResultsWARNING:root:Initial mole fractions do not sum to one; normalizing. Detailed regression test results.Regression test aromatics:Reference: Execution time (DD:HH:MM:SS): 00:00:01:06 aromatics Passed Core Comparison ✅Original model has 15 species. aromatics Failed Edge Comparison ❌Original model has 106 species. Non-identical thermo! ❌
Identical thermo comments:
Observables Test Case: Aromatics Comparison
✅ All Observables varied by less than 0.500 on average between old model and new model in all conditions! aromatics Passed Observable Testing ✅Regression test liquid_oxidation:Reference: Execution time (DD:HH:MM:SS): 00:00:02:10 liquid_oxidation Failed Core Comparison ❌Original model has 37 species. liquid_oxidation Failed Edge Comparison ❌Original model has 202 species. Non-identical kinetics! ❌
kinetics:
Observables Test Case: liquid_oxidation Comparison
✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions! liquid_oxidation Passed Observable Testing ✅Regression test nitrogen:Reference: Execution time (DD:HH:MM:SS): 00:00:01:28 nitrogen Passed Core Comparison ✅Original model has 41 species. nitrogen Passed Edge Comparison ✅Original model has 133 species.
Observables Test Case: NC Comparison
✅ All Observables varied by less than 0.200 on average between old model and new model in all conditions! nitrogen Passed Observable Testing ✅Regression test oxidation:Reference: Execution time (DD:HH:MM:SS): 00:00:02:27 oxidation Passed Core Comparison ✅Original model has 59 species. oxidation Passed Edge Comparison ✅Original model has 230 species.
Observables Test Case: Oxidation Comparison
✅ All Observables varied by less than 0.500 on average between old model and new model in all conditions! oxidation Passed Observable Testing ✅Regression test sulfur:Reference: Execution time (DD:HH:MM:SS): 00:00:00:56 sulfur Passed Core Comparison ✅Original model has 27 species. sulfur Failed Edge Comparison ❌Original model has 89 species.
Observables Test Case: SO2 Comparison
The following observables did not match: ❌ Observable species O=S=O varied by more than 0.100 on average between old model SO2(15) and new model SO2(15) in condition 1.
sulfur Failed Observable Testing ❌Regression test superminimal:Reference: Execution time (DD:HH:MM:SS): 00:00:00:39 superminimal Passed Core Comparison ✅Original model has 13 species. superminimal Passed Edge Comparison ✅Original model has 18 species. Regression test RMS_constantVIdealGasReactor_superminimal:Reference: Execution time (DD:HH:MM:SS): 00:00:02:22 RMS_constantVIdealGasReactor_superminimal Passed Core Comparison ✅Original model has 13 species. RMS_constantVIdealGasReactor_superminimal Passed Edge Comparison ✅Original model has 13 species.
Observables Test Case: RMS_constantVIdealGasReactor_superminimal Comparison
✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions! RMS_constantVIdealGasReactor_superminimal Passed Observable Testing ✅Regression test RMS_CSTR_liquid_oxidation:Reference: Execution time (DD:HH:MM:SS): 00:00:05:53 RMS_CSTR_liquid_oxidation Passed Core Comparison ✅Original model has 37 species. RMS_CSTR_liquid_oxidation Passed Edge Comparison ✅Original model has 206 species.
Observables Test Case: RMS_CSTR_liquid_oxidation Comparison
✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions! RMS_CSTR_liquid_oxidation Passed Observable Testing ✅Regression test fragment:Reference: Execution time (DD:HH:MM:SS): 00:00:00:43 fragment Passed Core Comparison ✅Original model has 10 species. fragment Passed Edge Comparison ✅Original model has 33 species.
Observables Test Case: fragment Comparison
✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions! fragment Passed Observable Testing ✅Regression test RMS_constantVIdealGasReactor_fragment:Reference: Execution time (DD:HH:MM:SS): 00:00:03:04 RMS_constantVIdealGasReactor_fragment Passed Core Comparison ✅Original model has 10 species. RMS_constantVIdealGasReactor_fragment Passed Edge Comparison ✅Original model has 27 species.
Observables Test Case: RMS_constantVIdealGasReactor_fragment Comparison
✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions! RMS_constantVIdealGasReactor_fragment Passed Observable Testing ✅beep boop this comment was written by a bot 🤖 |
This pull request is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant pull request, otherwise it will automatically be closed in 30 days. |
Replaces #2597
Motivation or Problem
The conversion to Cantera YAML files currently implemented in #2321 involves converting things to Cantera objects in memory then having Cantera return the properties. That revealed that some to_cantera methods were missing, namely for surface kinetics, and went about adding them.
Meanwhile #2597 added some to_cantera methods for surface kinetics to enable creating and updating Cantera simulations.
Description of Changes
This PR takes both those, merges them, cleans them up a bit, and adds unit tests.
Testing
I added and extended unit tests that reads a small chemkin file and compares the results of chemkinfile->RMG->Cantera vs chemkinfile->ck2yaml->Cantera.
Additional notes
#2321 has been rebased to separate out these changes from the YAML-writing changes, so this can be reviewed and merged first, and that PR will be greatly shorter.
This replaces #2597 which can be closed once this is merged.