Rate of Production and Sensitivity Plots for 1-D Flame

848 views
Skip to first unread message

katie.c...@gmail.com

unread,
Oct 1, 2018, 8:43:56 PM10/1/18
to Cantera Users' Group
Hi All, 

I am very new to Cantera, I have been using Chemkin but no longer have a license for it. I was wondering if there was a way to create sensitivity and rate of production plots for a specific species as a function of distance from the burner like I was able to in Chemkin? (I have attached plots as examples). I am using python 2.7 and cantera 2.4.0 running on windows. I have attached the script for an ethanol flame I am hoping to edit to be able to plot rate of production and sensitivity, and the mechanism I am currently using. 

Any advice would be appreciated. 

Thank you, 

Katie 
Sensitivity Example.png
ROP Example.png
aramcoMech.cti
Burner_withTemp.py

Bryan W. Weber

unread,
Oct 5, 2018, 7:57:19 PM10/5/18
to Cantera Users' Group
Hi Katie,

Welcome to Cantera! I'm glad that you're using Cantera 2.4.0, but I would suggest that you update from legacy Python to Python 3, since Cantera 2.4.0 will be the last version of Cantera that supports Python 2.

Anyways, to answer your questions. Cantera can definitely calculate the ROP of any species; you can use the net_rates_of_progress array and the stoichiometric coefficients to calculate the ROP per reaction like

net_stoich_coeffs = f.gas.product_stoich_coeffs() - f.gas.reactant_stoich_coeffs()
for i in len(f.grid):
    ropr
= f.net_rates_of_progress[:, i]
    rop
= ropr*net_stoich_coeffs

Then you can index the rop array (which has shape n_species, n_reactions) to find the species that you're interested.

I'm less sure about the sensitivity, but you should be able to follow the example of the get_flame_speed_reaction_sensitivity function, replacing references to 'u' with the species that you're interested in.

Best
Bryan

Rodolfo Rocha

unread,
Oct 18, 2018, 9:05:56 PM10/18/18
to Cantera Users' Group
Hello everyone,

I have been trying unsuccessfully to calculate the sensitivity for each reaction at each point in the grid with the suggested method. I tried to replace the 'u' references with a species variable in a separate function (for species a string like 'CO', 'CO2', etc.). My code is this:
def get_species_reaction_sensitivities(self, species, grid_point):
r"""
Compute the normalized sensitivities of the species production
:math:`s_{i, spec}` with respect to the reaction rate constants :math:`k_i`:
.. math::
s_{i, spec} = \frac{k_i}{[X]} \frac{d[X]}{dk_i}
"""

def g(sim):
return sim.X[self.gas.species_index(species), grid_point]

Nvars = sum(D.n_components * D.n_points for D in self.domains)

# Index of u[0] in the global solution vector
i_spec = self.inlet.n_components + self.flame.component_index(species)

dgdx = np.zeros(Nvars)
dgdx[i_spec] = 1

spec_0 = g(self)

def perturb(sim, i, dp):
sim.gas.set_multiplier(1+dp, i)

return self.solve_adjoint(perturb, self.gas.n_reactions, dgdx) / spec_0
For 'self' being the flame object. It gives me the same value divided by the species concentration in each point, which means that the value of 
self.solve_adjoint(perturb, self.gas.n_reactions, dgdx)
is always the same.
How can I solve it? Could someone who already figured it out help?

Thank you very much,

Rodolfo Rocha

unread,
Oct 25, 2018, 10:45:16 AM10/25/18
to Cantera Users' Group
I am beginning to think that my problem is exactly at one point: the original perturb function somehow affects an average (or a fixed value) of the k_i for each reaction, but not the k_i(z) for the reactions in each z point in the grid. Do you know how to do it?

Rodolfo Rocha

unread,
Oct 30, 2018, 10:26:08 AM10/30/18
to Cantera Users' Group
Hello everybody,

I am very close to solving it, but I still need some help with a couple things...
I adapted the i_spec in code to i_spec = self.inlet.n_components + self.flame.component_index(species) + self.domains[1].n_components*grid_point , as suggested in another topic (https://groups.google.com/forum/#!topic/cantera-users/vfejZRDKKuw). The values I got for the FreeFlame case were a bit strange, were higher than 1 before the flame. I'm sending you attached a plot as an example. For the BurnerFlame, however, there is no f.inlet, which makes it harder to find the correct index for the species.
Do you know how to fix it?
Thank you very much for the attention.

Regards,
Figure_1.png

Ray Speth

unread,
Nov 11, 2018, 7:56:15 PM11/11/18
to Cantera Users' Group
Rodolfo,

For the burner flame, the domain defining the left boundary is named 'burner', rather than 'inlet', as described in the documentation for the BurnerFlame class.

Regards,
Ray

Regards,
Ray

Rodolfo Rocha

unread,
Dec 21, 2018, 3:09:53 PM12/21/18
to Cantera Users' Group
Hello Ray,

It worked like a charm. Thank you!
One change I did to lower the values was to reduce the perturbation, dgdx, as done in https://charlesreid1.com/wiki/Cantera/Sensitivity_Analysis , but it did not change the shape. Anyway, I only needed flame sensitivity in the flame region after all, so, it worked for me.

Best regards,
Reply all
Reply to author
Forward
0 new messages