ReactionMechanismGenerator / RMG-Py

Python version of the amazing Reaction Mechanism Generator (RMG).
http://reactionmechanismgenerator.github.io/RMG-Py/
Other
400 stars 228 forks source link

Coverage-dependent thermochemistry for catalysis #2646

Open 12Chao opened 8 months ago

12Chao commented 8 months ago

Motivation or Problem

This PR adds in coverage dependent thermodynamic models for heterogeneous catalysis modeling. An adsorbate's enthalpy and entropy should be affected by other adsorbates around it. The PR enables RMG to use a polynomial model to estimate the change of an adsorbate's enthalpy or entropy based on the coverage of other adsorbates on the catalyst surface. By doing this, a Cantera yaml file with thermodynamic coverage dependent data can be generated at the end of a RMG simulation, and it can be used by Cantera (>=3.0) to run PFR simulation. RMG looks into the database to read the thermo coverage dependent models.

Description of Changes

surface.pyx file is modified to change the species enthalpy and entropy based on the coverage dependent (polynomial) models in the database. nasa.pyx, wilhoit.pyx, and thermodata.pyx are all modified to be able to save the thermo coverage dependent model for each species. main.py is modified to be able to incorporate thermo coverage dependence modeling as an option and be able to write Cantera yaml file with thermo coverage models in.

Testing

Unit tests are added in thermo and solver folders to test if a species with thermo coverage dependent model can be created and whether the simulation can be run. To further test the effect to the model generation, a thermo database is made up with the thermo coverage-dependent models, and the data base was used to make a CPOX model on Pt. In the CPOX on Pt model, OX self interaction and COX self interaction are included. The model was then run through a PFR simulation with Cantera 3.0, a significant drop of coverage of COX on the surface was observed, and therefore validate the code modification. Test files are attached here. test.zip

Reviewer Tips

Please try to pull the changes from this branch and used the database provided in the test.zip to generate a model of your own choice see if it makes any difference to your model compared to without thermo cov dependent model. You can also generate a model with the RMG input file provided in the test.zip, then in the input file turn thermoCoverageDependence to False to generate another model without coverage dependence. Then use simultion.py in test.zip to run simulations for the two RMG models generated to test if there is any difference in the simulation results.

github-actions[bot] commented 8 months ago

Regression Testing Results

⚠️ One or more regression tests failed. Please download the failed results and run the tests locally or check the log to see why.

Detailed regression test results. ### Regression test aromatics: Reference: Execution time (DD:HH:MM:SS): 00:00:01:05 Current: Execution time (DD:HH:MM:SS): 00:00:01:05 Reference: Memory used: 2775.86 MB Current: Memory used: 2793.33 MB
aromatics Passed Core Comparison ✅ Original model has 15 species. Test model has 15 species. ✅ Original model has 11 reactions. Test model has 11 reactions. ✅
aromatics Failed Edge Comparison ❌ Original model has 106 species. Test model has 106 species. ✅ Original model has 358 reactions. Test model has 358 reactions. ✅ Non-identical thermo! ❌ original: `C=CC1C=CC2=CC1C=C2` tested: `C=CC1C=CC2=CC1C=C2` |Hf(300K) |S(300K) |Cp(300K) |Cp(400K) |Cp(500K) |Cp(600K) |Cp(800K) |Cp(1000K) |Cp(1500K) | |----------|----------|----------|----------|----------|----------|----------|----------|----------| | 83.22| 82.78| 35.48| 45.14| 53.78| 61.40| 73.58| 82.20| 95.08| | 83.22| 84.16| 35.48| 45.14| 53.78| 61.40| 73.58| 82.20| 95.08| Identical thermo comments: thermo: Thermo group additivity estimation: group(Cs-(Cds-Cds)(Cds-Cds)CsH) + group(Cs-(Cds-Cds)(Cds-Cds)CsH) + group(Cds-Cds(Cds-Cds)(Cds-Cds)) + group(Cds- CdsCsH) + group(Cds-CdsCsH) + group(Cds-CdsCsH) + group(Cds-CdsCsH) + group(Cds-Cds(Cds-Cds)H) + group(Cds-Cds(Cds-Cds)H) + group(Cds-CdsHH) + Estimated bicyclic component: polycyclic(s3_5_6_ane) - ring(Cyclohexane) - ring(Cyclopentane) + ring(1,3-Cyclohexadiene) + ring(Cyclopentadiene)
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:08 Current: Execution time (DD:HH:MM:SS): 00:00:02:09 Reference: Memory used: 2895.55 MB Current: Memory used: 2918.08 MB
liquid_oxidation Failed Core Comparison ❌ Original model has 37 species. Test model has 37 species. ✅ Original model has 216 reactions. Test model has 216 reactions. ✅ Non-identical kinetics! ❌ original: rxn: `CCCC(C)O[O](20) + CCCCCO[O](103) <=> oxygen(1) + CCCC(C)[O](64) + CCCCC[O](128)` origin: Peroxyl_Disproportionation tested: rxn: `CCCC(C)O[O](20) + CCCCCO[O](104) <=> oxygen(1) + CCCC(C)[O](61) + CCCCC[O](127)` origin: Peroxyl_Disproportionation |k(1bar)|300K |400K |500K |600K |800K |1000K |1500K |2000K | |-------|-------|-------|-------|-------|-------|-------|-------|-------| |k(T): | 3.77| 4.45| 4.86| 5.14| 5.48| 5.68| 5.96| 6.09| |k(T): | 7.83| 7.49| 7.23| 7.02| 6.68| 6.42| 5.95| 5.61| kinetics: `Arrhenius(A=(3.2e+12,'cm^3/(mol*s)'), n=0, Ea=(3.756,'kcal/mol'), T0=(1,'K'), comment="""Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing_Ext-5R-R""")` kinetics: `Arrhenius(A=(3.18266e+20,'cm^3/(mol*s)'), n=-2.694, Ea=(0,'kcal/mol'), T0=(1,'K'), comment="""Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing""")` kinetics: Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing_Ext-5R-R kinetics: Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing
liquid_oxidation Failed Edge Comparison ❌ Original model has 202 species. Test model has 202 species. ✅ Original model has 1610 reactions. Test model has 1613 reactions. ❌ The original model has 1 reactions that the tested model does not have. ❌ rxn: `CCCCCO[O](103) + CCCCCO[O](103) <=> oxygen(1) + CCCCC=O(120) + CCCCCO(130)` origin: Peroxyl_Termination The tested model has 4 reactions that the original model does not have. ❌ rxn: `C[CH]CCCO(157) + CCCCCO[O](104) <=> CC=CCCO(183) + CCCCCOO(105)` origin: Disproportionation rxn: `C[CH]CCCO(157) + CCCCCO[O](104) <=> C=CCCCO(184) + CCCCCOO(105)` origin: Disproportionation rxn: `C[CH]CCCO(157) + C[CH]CCCO(157) <=> CC=CCCO(183) + CCCCCO(130)` origin: Disproportionation rxn: `C[CH]CCCO(157) + C[CH]CCCO(157) <=> C=CCCCO(184) + CCCCCO(130)` origin: Disproportionation Non-identical kinetics! ❌ original: rxn: `CCCC(C)O[O](20) + CCCCCO[O](103) <=> oxygen(1) + CCCC(C)[O](64) + CCCCC[O](128)` origin: Peroxyl_Disproportionation tested: rxn: `CCCC(C)O[O](20) + CCCCCO[O](104) <=> oxygen(1) + CCCC(C)[O](61) + CCCCC[O](127)` origin: Peroxyl_Disproportionation |k(1bar)|300K |400K |500K |600K |800K |1000K |1500K |2000K | |-------|-------|-------|-------|-------|-------|-------|-------|-------| |k(T): | 3.77| 4.45| 4.86| 5.14| 5.48| 5.68| 5.96| 6.09| |k(T): | 7.83| 7.49| 7.23| 7.02| 6.68| 6.42| 5.95| 5.61| kinetics: `Arrhenius(A=(3.2e+12,'cm^3/(mol*s)'), n=0, Ea=(3.756,'kcal/mol'), T0=(1,'K'), comment="""Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing_Ext-5R-R""")` kinetics: `Arrhenius(A=(3.18266e+20,'cm^3/(mol*s)'), n=-2.694, Ea=(0,'kcal/mol'), T0=(1,'K'), comment="""Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing""")` kinetics: Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing_Ext-5R-R kinetics: Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing Non-identical kinetics! ❌ original: rxn: `CCCCCO[O](103) + CC(CC(C)OO)O[O](104) <=> oxygen(1) + CCCCC[O](128) + CC([O])CC(C)OO(127)` origin: Peroxyl_Disproportionation tested: rxn: `CCCCCO[O](104) + CC(CC(C)OO)O[O](103) <=> oxygen(1) + CCCCC[O](127) + CC([O])CC(C)OO(129)` origin: Peroxyl_Disproportionation |k(1bar)|300K |400K |500K |600K |800K |1000K |1500K |2000K | |-------|-------|-------|-------|-------|-------|-------|-------|-------| |k(T): | 3.52| 4.27| 4.71| 5.01| 5.39| 5.61| 5.91| 6.06| |k(T): | 7.79| 7.46| 7.21| 7.00| 6.67| 6.41| 5.94| 5.60| kinetics: `Arrhenius(A=(3.2e+12,'cm^3/(mol*s)'), n=0, Ea=(4.096,'kcal/mol'), T0=(1,'K'), comment="""Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing_Ext-5R-R""")` kinetics: `Arrhenius(A=(3.18266e+20,'cm^3/(mol*s)'), n=-2.694, Ea=(0.053,'kcal/mol'), T0=(1,'K'), comment="""Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing Ea raised from 0.0 to 0.2 kJ/mol to match endothermicity of reaction.""")` kinetics: Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing_Ext-5R-R kinetics: Estimated from node Root_Ext-5R-R_7R!H->C_N-7C-inRing Ea raised from 0.0 to 0.2 kJ/mol to match endothermicity of reaction.
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:22 Current: Execution time (DD:HH:MM:SS): 00:00:01:23 Reference: Memory used: 2909.03 MB Current: Memory used: 2919.82 MB
nitrogen Passed Core Comparison ✅ Original model has 41 species. Test model has 41 species. ✅ Original model has 360 reactions. Test model has 360 reactions. ✅
nitrogen Passed Edge Comparison ✅ Original model has 132 species. Test model has 132 species. ✅ Original model has 997 reactions. Test model has 997 reactions. ✅
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:22 Current: Execution time (DD:HH:MM:SS): 00:00:02:22 Reference: Memory used: 2764.76 MB Current: Memory used: 2775.02 MB
oxidation Passed Core Comparison ✅ Original model has 59 species. Test model has 59 species. ✅ Original model has 694 reactions. Test model has 694 reactions. ✅
oxidation Passed Edge Comparison ✅ Original model has 230 species. Test model has 230 species. ✅ Original model has 1526 reactions. Test model has 1526 reactions. ✅
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:54 Current: Execution time (DD:HH:MM:SS): 00:00:00:54 Reference: Memory used: 2876.49 MB Current: Memory used: 2867.09 MB
sulfur Passed Core Comparison ✅ Original model has 27 species. Test model has 27 species. ✅ Original model has 74 reactions. Test model has 74 reactions. ✅
sulfur Failed Edge Comparison ❌ Original model has 89 species. Test model has 89 species. ✅ Original model has 227 reactions. Test model has 227 reactions. ✅ The original model has 1 reactions that the tested model does not have. ❌ rxn: `O(4) + SO2(15) (+N2) <=> SO3(16) (+N2)` origin: primarySulfurLibrary The tested model has 1 reactions that the original model does not have. ❌ rxn: `O(4) + SO2(15) (+N2) <=> SO3(16) (+N2)` origin: primarySulfurLibrary
Observables Test Case: SO2 Comparison ✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions! sulfur Passed Observable Testing ✅
### Regression test superminimal: Reference: Execution time (DD:HH:MM:SS): 00:00:00:35 Current: Execution time (DD:HH:MM:SS): 00:00:00:35 Reference: Memory used: 2980.01 MB Current: Memory used: 2989.79 MB
superminimal Passed Core Comparison ✅ Original model has 13 species. Test model has 13 species. ✅ Original model has 21 reactions. Test model has 21 reactions. ✅
superminimal Passed Edge Comparison ✅ Original model has 18 species. Test model has 18 species. ✅ Original model has 28 reactions. Test model has 28 reactions. ✅
### Regression test RMS_constantVIdealGasReactor_superminimal: Reference: Execution time (DD:HH:MM:SS): 00:00:02:24 Current: Execution time (DD:HH:MM:SS): 00:00:02:25 Reference: Memory used: 3457.63 MB Current: Memory used: 3446.78 MB
RMS_constantVIdealGasReactor_superminimal Passed Core Comparison ✅ Original model has 13 species. Test model has 13 species. ✅ Original model has 19 reactions. Test model has 19 reactions. ✅
RMS_constantVIdealGasReactor_superminimal Passed Edge Comparison ✅ Original model has 13 species. Test model has 13 species. ✅ Original model has 19 reactions. Test model has 19 reactions. ✅
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:06:07 Current: Execution time (DD:HH:MM:SS): 00:00:06:08 Reference: Memory used: 3371.70 MB Current: Memory used: 3386.42 MB
RMS_CSTR_liquid_oxidation Failed Core Comparison ❌ Original model has 37 species. Test model has 37 species. ✅ Original model has 233 reactions. Test model has 232 reactions. ❌ The original model has 1 reactions that the tested model does not have. ❌ rxn: `CCO[O](36) <=> [OH](22) + CC=O(61)` origin: intra_H_migration
RMS_CSTR_liquid_oxidation Failed Edge Comparison ❌ Original model has 206 species. Test model has 206 species. ✅ Original model has 1508 reactions. Test model has 1508 reactions. ✅ The original model has 2 reactions that the tested model does not have. ❌ rxn: `CCO[O](36) <=> [OH](22) + CC=O(61)` origin: intra_H_migration rxn: `CCCO[O](35) <=> CC[CH]OO(45)` origin: intra_H_migration The tested model has 2 reactions that the original model does not have. ❌ rxn: `CCCO[O](35) <=> [OH](21) + CCC=O(50)` origin: intra_H_migration rxn: `CCO[O](36) <=> C[CH]OO(63)` origin: intra_H_migration
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:40 Current: Execution time (DD:HH:MM:SS): 00:00:00:40 Reference: Memory used: 2698.19 MB Current: Memory used: 2722.21 MB
fragment Passed Core Comparison ✅ Original model has 10 species. Test model has 10 species. ✅ Original model has 2 reactions. Test model has 2 reactions. ✅
fragment Passed Edge Comparison ✅ Original model has 33 species. Test model has 33 species. ✅ Original model has 47 reactions. Test model has 47 reactions. ✅
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:03 Current: Execution time (DD:HH:MM:SS): 00:00:03:05 Reference: Memory used: 3595.30 MB Current: Memory used: 3578.98 MB
RMS_constantVIdealGasReactor_fragment Passed Core Comparison ✅ Original model has 10 species. Test model has 10 species. ✅ Original model has 2 reactions. Test model has 2 reactions. ✅
RMS_constantVIdealGasReactor_fragment Passed Edge Comparison ✅ Original model has 27 species. Test model has 27 species. ✅ Original model has 24 reactions. Test model has 24 reactions. ✅
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 :robot:

codecov[bot] commented 8 months ago

Codecov Report

Attention: Patch coverage is 24.39024% with 31 lines in your changes missing coverage. Please review.

Project coverage is 54.83%. Comparing base (a458b1d) to head (5411e20). Report is 50 commits behind head on main.

Files Patch % Lines
rmgpy/rmg/main.py 9.09% 30 Missing :warning:
rmgpy/rmg/input.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2646 +/- ## ========================================== - Coverage 54.86% 54.83% -0.03% ========================================== Files 125 125 Lines 37050 37091 +41 ========================================== + Hits 20326 20340 +14 - Misses 16724 16751 +27 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 4 months ago

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.

github-actions[bot] commented 1 month ago

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.