Questions about Cantera reaction mechanism and Python implementation of Plug Flow Reactor

201 views
Skip to first unread message

Partth

unread,
Jun 30, 2024, 10:03:18 AM6/30/24
to Cantera Users' Group
Hi All,

This is my first post so apologies if I am not formatting this correctly/this may be too general. I am currently working on writing a steady-state flow solver and wish to use Cantera to compute the finite rate chemistry in Python; I am seeking to reproduce and modify an existing code which uses an external CFD solver dependency to perform the finite-rate chemistry.

For my first concern: I was able to define the requisite species properties and mechanism along with my ODE solver. I am able to get the net rate of species formation for a specified gas solution using " gas.net_production_rates", but my issue is that I am not sure how to update the reaction steps of the mechanism as I am not getting the correct species mass fraction/production along each iteration of the solver. I would share my code here, but since it is part of my research group I cannot, I will try to privately message someone if they can see what I may be doing incorrectly as it essentially and ODE solver but my incorporation of Cantera is not quite working. 

As in, is there a way to update the state of the gas solution as I am supplying the updated temp, pressure and mass fraction on each iteration to the gas, but my rate of production/gas state does not seem to reflect the combustion that should occur. I think I am just evaluating a new solution/state for my gas each iteration but it is not actually proceeding with the reactions/producing the heat release.

I saw there is a reactor module for transient combustion, but I am more concerned with SS combustion so I do not think the "custom.py" example is directly applicable though I could be wrong. If I make the time variable t (which seems to be integrated in the ODE solver) a stand-in for the spatial direction x, I could probably write my steady-state equations to be solved in terms of "t" or is this not quite right?

For my second concern: I saw a suitable alternative would be the use of a plug-flow solver as this integrate the governing equations and use Cantera as I wished in the prior part. However, I saw that the Python implementation assumes a constant pressure as compared to the MATLAB version of the Plug Flow Reactor (PFR). Is this still the case? I was seeking to develop something based off of this: https://cantera.org/dev/examples/matlab_experimental/plug_flow_reactor.html so I may indeed have to use MATLAB if the pressure is indeed constant in the Python PFR.

A question I had: I understand there are extensible reactors such as this example: https://cantera.org/examples/python/reactors/PorousMediaBurner.py.html in which the governing equations can be modified/additional state variables can be defined, but can additional ODEs be added to  the given set solved by the PFR, or is this a constraint.

If anyone can shed light on these matters it would help a lot. Else, worst case, if I cannot incorporate Cantera, I would have to solve the finite chemistry manually which defeats the purpose herein. Thank you.

Ray Speth

unread,
Jul 7, 2024, 4:01:08 PM7/7/24
to Cantera Users' Group

Hi,

You’ve got a lot of questions packed in here. I’ll try to address a few of them.

Regarding the calculation of net production rates and the state changing: This is very basic functionality for Cantera. If you change the temperature, pressure or composition of a Solution object, the calculation of the net production rates will reflect the new state. If you’re not seeing this, then there may be some issue with how you’re either setting the state or accessing the kinetic rates. The only way for us to help would be if you could provide at least a minimal example that shows the behavior you’re observing.

I’m somewhat unclear on what the equations you want Cantera to solve are. Is the situation you’re interested in representing a 1D steady flow? If so, you may be able to use Cantera’s reactor network model with a Lagrangian interpretation to map the integrator time onto the spatial dimension. This approach is demonstrated by the first case of this example.

Yes, the ExtensibleReactor capability allows you to add extra ODEs to the system of equations being solved. This example shows a case where this is done, using the extra equation to represent a state variable for an adjacent moving wall. Note that the ExtensibleReactor capability is not currently compatible with the FlowReactor class, so you would need to represent your system in the time domain as in the previous case.

I would not recommend using the experimental version of the Matlab toolbox just yet — it is still a work in progress.

Regards,
Ray

Partth

unread,
Jul 7, 2024, 11:25:20 PM7/7/24
to Cantera Users' Group
Hi Ray,

Thanks for taking the time respond.

1) I missed this example so thanks for sharing; I will definitely look more into this as it seems this is what I am trying to do (transformation to allow integrating in space). 
2) Ok, thanks for clarifying; this is quite useful to know. In this case, I could similarly define the governing equations for the ExtensibleReactor and then use the Lagrangian interpretation to convert the extensible reactor system to spatial domain, correct?

I think I have got my initial approach of integrating ODEs with Cantera to update the chemistry (it ended up being an issue in unit conversion from the production rate which is why chemistry was not proceeding...), but I would like to make a study in comparing this approach against the Lagrangian-ExtensibleReactor approach.

This helps a lot!

-Partth
Reply all
Reply to author
Forward
0 new messages