All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: To write a Python code using the Cantera module to determine and plot the \'n\' number of most sensitive reactions to Temperature out of the \'N\' number of total reactions in the GRI30 mechanism for the auto-ignition of methane. Python Script: The following Python script demonstrates how to determine and plot…
Siva Prasad
updated on 01 Aug 2019
Objective:
To write a Python code using the Cantera module to determine and plot the \'n\' number of most sensitive reactions to Temperature out of the \'N\' number of total reactions in the GRI30 mechanism for the auto-ignition of methane.
Python Script:
The following Python script demonstrates how to determine and plot the \'n\' (=10) number of most sensitive reactions to Temperature out of the \'N\' (=100) foremost reactions in the GRI30 mechanism file for the auto-ignition of CH4;
\"\"\"
To write a Python code using the Cantera module to determine and plot the \'n\' number of most sensitive reactions to Temperature out of the \'N\' number of total reactions in the GRI30 mechanism for the auto-ignition of methane.
\"\"\"
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
# total number of reaction parameters being considered
n_param = 100
S_max = [0]*n_param
# number of most sensitive reactions to be plotted
n_plot = 10
S_plot = [0]*n_plot
# time control
t_end = 2e-3
dt = 5e-6
gas = ct.Solution(\'gri30.cti\')
temp = 1500 # K
pres = ct.one_atm # Pa
gas.TPX = temp, pres, \'CH4:1, O2:2, N2:7.52\'
r = ct.IdealGasConstPressureReactor(gas)
sim = ct.ReactorNet([r])
# including all the reaction parameters with respect to which the Temperature sensitivity is computed
for i in range(n_param):
r.add_sensitivity_reaction(i)
# setting tolerances
sim.rtol = 1e-6
sim.atol = 1e-15
sim.rtol_sensitivity = 1e-6
sim.atol_sensitivity = 1e-6
# time integration loop
for t in np.arange(0, t_end, dt):
sim.advance(t)
# computing sensitivities for each reaction at every time step
for j in range(n_param):
S = sim.sensitivity(1, j)
# checking for maximum sensitivity value at each time step for every reaction
if np.abs(S) > np.abs(S_max[j]):
S_max[j] = S
label = []
# gleaning the \'n_plot\' most sensitive reactions from \'n-param\' total reactions
for k in range(n_plot):
maximum = np.max(S_max)
minimum = np.min(S_max)
# storing the most sensitive reactions inside \'S_plot\' in the descending order of sensitivities
if np.abs(maximum) > np.abs(minimum):
S_plot[k] = maximum
reaction_index = S_max.index(maximum)
label.append(sim.sensitivity_parameter_name(reaction_index))
S_max.remove(maximum)
else:
S_plot[k] = minimum
reaction_index = S_max.index(minimum)
label.append(sim.sensitivity_parameter_name(reaction_index))
S_max.remove(minimum)
# printing results
for i in range(n_plot):
print(label[i],\'\\t\', S_plot[i])
# deleting/replacing the redundant characters in each reaction label inside string array \'label\'
red_chars = \'IdealGasConstPressureReactor_1: \'
rep = \'\'
for r in range(len(label)):
label[r] = label[r].replace(red_chars, rep)
# decreasing the \'Y\' axis ticklabel size
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.tick_params(axis=\'y\', labelsize=8)
# plotting the desired results
plt.title(\'Most sensitive reaction parameters to Temperature\\nin the auto-ignition of CH4\')
plt.barh(label, S_plot)
plt.xlabel(\'Temperature sensitivity\')
plt.tight_layout()
plt.show()
Result:
The sensitivity analysis result obtained for the auto-ignition of CH4 is shown below. This result corresponds to the 10 most sensitive reactions of the top 100 reactions in the GRI30 mechanism.
The data for the above plot is tabulated below;
Inference:
We can infer from the above plot that the reversible reaction involving oxidation of H to form OH contributes the highest to temperature rise or in other words, is the most sensitive to temperature. However, the second most sensitive reaction, i.e., the reduction of CH3 to form CH4 contributes negatively to the Temperature rise. In other words, it decelerates the temperature rise. Similarly, there are more reactions that contribute to temperature rise in a positive or negative manner with varying degrees as can be seen in the plot above.
The sensitivity analysis is essential in optimizing the performance of IC engines, especially the compression ignition types where the combustion process is initiated by the auto-ignition of fuel. In such a process, the auto-ignition delay needs to precisely align with the movement of the piston for optimum efficiency. This is where the sensitivity analysis is done, the most sensitive reactions are determined and the reaction rates are altered to get the desired ignition delay.
As in the above plot, the ignition delay can be increased by decreasing the rate of the reaction \'H + O2 <-> O + OH\' or by increasing the rate of the reaction \'CH3 + H(+M) <-> CH4(+M)\' and vice-versa.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 3 - 2D meshing for Sheet metal
Hi there, Test
01 Aug 2023 10:33 AM IST
Deriving fourth order scheme for central and skewed difference approximations for a second order derivative using Taylor s table and graphically comparing the errors resulting from these approaches
Objective To derive the fourth order approximation schemes for the second order derivative of a function using central differencing, skewed right side differencing and skewed left side differencing approach and to draw a comparison between the errors arising from these approaches along with forward and backward differencing…
12 Dec 2019 07:57 AM IST
Deriving the Reynold s Averaged Navier-Stokes RANS Equations- Literature Review
Objective: To derive the Reynold\'s Averaged Navier-Stokes (RANS) equations Solution: The Reynold\'s Averaged Navier-Stokes equations are NS equations that are time-averaged after applying Reynold\'s decomposition technique to the General NS equations. Solving the Navier-Stokes equations directly (Direct Numerical…
06 Nov 2019 04:13 AM IST
Shock Tube simulation in Converge CFD
Objective: To set up a transient shock tube simulation in Converge CFD and to post-process the results in Paraview. Theory- Shock tube A shock tube is a device used to generate shocks. This device is used in experiments for determining the ignition delay of fuel when subjected to the auto-ignition temperature. The generated…
25 Oct 2019 05:38 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.