change A, b, Ea in memory

262 views
Skip to first unread message

Weiqi Ji

unread,
Mar 17, 2021, 8:33:09 PM3/17/21
to Cantera Users' Group
Hi,

I am working on optimizing reaction mechanisms, in which all of three Arrhenius parameters A, b, Ea are changed. Now, I want to test it in Cantera. I can thinking of two ways to do it:

1) manually (automatically) modify the mechanism file
2) modify A, b, Ea in memory.

Is there any way to do 2) in Cantera?

Thanks
Weiqi

Travis Sikes

unread,
Mar 17, 2021, 11:45:34 PM3/17/21
to canter...@googlegroups.com
Weiqi,

You should check out Frhodo. It optimizes all three arrhenius parameters and allows you to set uncertainties on them as well as the rate. All modification of the mechanism is done in memory. It's optimization is multiprocessing enabled. The version forked onto my github has Bayesian parameter estimation-based optimization (thanks to Ashi Savara and CHeKiPEUQ) as well as residual-based optimization. It also has quite a few other cool features. If there is something that you want it to do that it doesn't, it's open source. I'd love to work with you to add features.

Travis

--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cantera-users/7c8397d1-1b06-4500-b654-74d51cb181f1n%40googlegroups.com.
Message has been deleted
Message has been deleted

travis....@gmail.com

unread,
Mar 18, 2021, 10:36:58 AM3/18/21
to Cantera Users' Group
Weiqi,

There are a number of choices for optimization algorithms. For global optimization schemes it has stochastic methods, similar to what you mentioned, and ones which subdivide the parameter space into increasingly small hyperrectangles. Local optimization has options for simplex type methods and model based optimization. 

It's easier to answer your question directly as my implementation is bound up with my gui. You need to use modify_reaction(rxnIdx, rxn) where you specify what reaction is being modified and then provide it with a new reaction which you define. Changes made directly to the reaction do not change the underlying solution object until that function is called.

Travis
On Wednesday, March 17, 2021 at 10:55:29 PM UTC-5 Weiqi Ji wrote:
Hi Travis,

Can you point to the code block that modifies the mechanism in memory?

best,
Weiqi

Message has been deleted

Ray Speth

unread,
Mar 19, 2021, 11:55:42 AM3/19/21
to Cantera Users' Group

Hi Weiqi,

I added the modify_reaction functionality back in 2015, as part of Cantera 2.2. We don’t currently have any examples showing it’s use, so I guess it’s not very easy to discover.

Regards,
Ray

On Thursday, March 18, 2021 at 11:07:40 AM UTC-4 Weiqi Ji wrote:
Hi Travis,

Nice! I am curious if those methods work sufficiently well for large models with hundreds of parameters? I am mostly focusing on more sophistically methods developed for deep learning models and thus is good at complex models, even with thousands of parameters. Maybe we should schedule a call sometime to discuss :)

For the reaction modification, thanks for pointing out the function https://cantera.org/documentation/docs-2.5/sphinx/html/cython/kinetics.html#cantera.Kinetics.modify_reaction. I didn't know it and it seems added recently.
Currently, I wrote a short script to regenerate the updated mechanism with YAML.

Weiqi

Weiqi Ji

unread,
Mar 19, 2021, 2:12:34 PM3/19/21
to Cantera Users' Group
Hi Ray,

Good to know that. It is very useful for mechanism optimization and uncertainty quantification.

Best,
Weiqi

adityasa...@u.northwestern.edu

unread,
Mar 21, 2021, 7:48:54 PM3/21/21
to Cantera Users' Group
Weiqi, I'm not sure if you are using surface reactions. I remember there was some complication for surface reactions the last time I checked.  Because of that, I had to re-import the cantera model each optimization step.

But if you are using only gas phase reactions it should be fine. For optimizaition and UQ, I do think that Travis's software Frhodo is a good software for the community to continue to advance.

I had started building an interface for very general optimization: https://github.com/AdityaSavara/CheKiPEUQ/blob/master/CheKiPEUQ/simulationDriver/example_runfile.py

If you wish to build upon what I made further, that would be excellent also. I stopped working on it (for now) due to the Surface Reactions complication.

Ray Speth

unread,
Mar 23, 2021, 9:09:41 AM3/23/21
to Cantera Users' Group
Hi Aditya,

If there are aspects of surface reactions that can't be updated dynamically, can you please provide an example and post an issue on the GitHub Issue Tracker? In principle, there shouldn't be any problem with updating any parameters related to the rate constant. Some of the other parameters like efficiencies are more difficult to allow changes to.

Regards,
Ray

Aditya Ashi Savara

unread,
Mar 25, 2021, 10:22:28 PM3/25/21
to canter...@googlegroups.com
Will do! I thought I brought this up once but could not find evidence that I did so. I will try to put together an example in the next 5 days. I apologize for any delay as I have a couple of urgent deadlines!

You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/7YQ4yb5dC3M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cantera-users/af17a5a4-11f7-4b92-a2b3-8ab73377f9a7n%40googlegroups.com.

Ingmar Schoegl

unread,
Mar 26, 2021, 10:15:42 AM3/26/21
to Cantera Users' Group
Hi Aditya,
You did bring it up, but the issue was moved to 'enhancements', see https://github.com/Cantera/enhancements/issues/8
-ingmar-

adityasa...@u.northwestern.edu

unread,
Apr 7, 2021, 12:14:52 PM4/7/21
to Cantera Users' Group
Ingmar, thank you for finding my earlier enhancement request! It is nice to see I did make an example back then :)
Do I understand correctly that once MultiRateBase is merged in, you would expect the modify_reaction command to work correctly for surface reactions?

In case anybody reading this thread else wants to look, here are the relevant threads for the new code that has not yet been merged in.

Ingmar Schoegl

unread,
Apr 7, 2021, 12:44:35 PM4/7/21
to Cantera Users' Group
Hi Aditya,
MultiRateBase is already merged in, but the reactions need to be ported to the new framework. This will likely take a couple of PR's - see https://github.com/Cantera/enhancements/issues/87, and I anticipate InterfaceKinetics to be the last. It should, however, get fixed once the process is complete; if things proceed as anticipated it should also be possible to change some of the parameters directly in memory without having to modify/overwrite the reaction rate definition. It is, however, very much work in progress so take things with a grain of salt.
-ingmar-

Aditya Ashi Savara

unread,
Apr 7, 2021, 6:44:45 PM4/7/21
to canter...@googlegroups.com
Ingmar, thank you! That forward-looking information is very nice!

Reply all
Reply to author
Forward
0 new messages