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 the code which will take entire reactions of GRI mechanism 3.0 and take out the most sensitive top 10 reactions. The main parameters are as follows: Write code to list out the top 10 most sensitive reactions from a list of all reactions from the GRI mechanism. The sensitivity parameters should be with…
GAURAV KHARWADE
updated on 04 Jan 2021
Objective: To write the code which will take entire reactions of GRI mechanism 3.0 and take out the most sensitive top 10 reactions.
The main parameters are as follows:
Theory:
Sensitivity Analysis
In combustion huge numbers of reactions participate in the reaction, some of them are very crucial to ignite the mixture for given thermodynamic operating conditions. Hence, to find out which reactions are more sensitive for a given parameter, the sensitivity analysis technique is useful to its understanding.
In a sensitivity analysis, we will basically try to find out which reactions are very much sensitive to a parameter and which are less sensitive based on that we tune the reactions to satisfy the need under certain operating conditions. It is a process to get a relationship between the parameter and the output of the model. The main aim of this process is to calculate the ignition delay in the combustion and sensitivity analysis will tell us which reaction causes more ignition delay and we can adjust the mechanism reaction tuning.
GRI mechanism: This is the mechanism that will participate in the combustion process in our reactor. It contains 325 nos. of reactions. The analysis we perform here is the sensitivity of reaction against temperature.
The transient implicit scheme is used to solve the whole mechanism.
Python code:
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt
import os
# Constant pressure reactor with sensitivity analysis
gas = ct.Solution('gri30.xml')
# Initial Conditions
T= 1500
P= ct.one_atm
n= int(325) # nos.of reactions from GRI 3.0 mechanism
s_min= [0]*325
n_r=[]
gas.TPX= T,P,'CH4:1, O2:2, N2:7.52' # Methane as a fuel
r= ct.IdealGasConstPressureReactor()
r.insert(gas)
# To create a reactor network
sim= ct.ReactorNet([r])
# To add all reactions
for m in range(n):
r.add_sensitivity_reaction(m)
# To set the tolerances for the solution and for the sensitivity coefficients
sim.rtol= 1e-6
sim.atol= 1e-16
sim.rtol_sensitivity= 1e-5
sim.atol_sensitivity= 1e-6
# To create a solution array to store evoluted data
states= ct.SolutionArray(gas, extra=['t'])
# time-step
for t in np.arange(0,2e-3,5e-7):
sim.advance(t)
for j in range(n):
s= sim.sensitivity('temperature',j) # sensitivity of temerature, j represents nos. of reactions
if np.abs(s) >= np.abs(s_min[j]): # Condition to choose high sensitive reactions at corrosponding time.
s_min[j]= s
states.append(r.thermo.state, t= 1000*t)
print('%10.3e %10.3f %10.3f %14.6f'%(sim.time, r.T, r.thermo.P, r.thermo.u))
k = np.linspace(1,n,n)
sensitivity_list= (tuple(zip(k,s_min))) # to compile rection data and sensitive value
sensitivity_list_max= sorted(sensitivity_list, key=lambda sensitivity_list:-sensitivity_list[1]) # to sort the value in descending
# To select top 10 highly sensitive reactions.
names= []
sensitive_value= []
for l in range(10):
n_r1= sensitivity_list_max[l]
n_r2= int(n_r1[0])
n_r.append(n_r2)
n_r3= int(n_r1[1])
sensitive_value.append(n_r3)
# To access to OS and take out reaction string from GRI 3.0 file
os.chdir('D:\C5_Python\cantera\data')
for i in (n_r):
k= str(int(i))
#k= str(155)
file= open('gri30.cti','r')
ct=1
ct1=1
j=0
for line in file:
if 'Reaction' in line:
if k in line:
j=ct
ct= ct+1
file = open('gri30.cti','r')
for line in file:
if 'reaction('in line:
ct1= ct1+1
if ct1 == j:
names.append(line.split('"')[1])
#Plotting the results
fig, ax= plt.subplots(2,2)
ax[0,0].plot(states.t,states.T)
ax[0,0].set_title('Temperature and mole fraction in Reactor')
ax[0,0].set_xlabel('Time(ms)')
ax[0,0].set_ylabel('Temperature(K)')
ax[0,1].plot(states.t,states('OH').X)
ax[0,1].set_xlabel('Time(ms)')
ax[0,1].set_ylabel('OH mole fraction')
ax[1,0].plot(states.t,states('H').X)
ax[1,0].set_xlabel('Time(ms)')
ax[1,0].set_ylabel('H mole fraction')
ax[1,1].plot(states.t,states('CH4').X)
ax[1,1].set_xlabel('Time(ms)')
ax[1,1].set_ylabel('CH4 mole fraction')
fig.tight_layout()
x= np.linspace(0,9,10)
plt.figure(2)
plt.barh(x,sensitive_value)
plt.yticks(x,names)
plt.title('Sensitivities for GRI 3.0')
plt.grid('on')
plt.tight_layout()
plt.show()
Results:
From the above graph, we can clearly see that, the reaction CH3+O2→CH3O+O has a higher sensitivity coefficient, and the remaining 9 reactions show it has better control over which parameters to control to get desired results.
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 9 - Senstivity Analysis Assignment
Objective: To write the code which will take entire reactions of GRI mechanism 3.0 and take out the most sensitive top 10 reactions. The main parameters are as follows: Write code to list out the top 10 most sensitive reactions from a list of all reactions from the GRI mechanism. The sensitivity parameters should be with…
04 Jan 2021 05:51 PM IST
Auto ignition analysis of combustible mixture methane under different conditions using Cantera and Python
Objective: To study auto-ignition using Cantera. Following are the tasks to perform using Cantera: Plot the variation of Auto Ignition time of Methane with a constant temperature of 1250K and pressure varying from 1 to 5 atm. Plot the variation of Auto Ignition time…
06 Dec 2020 04:55 AM IST
Week 6 - Multivariate Newton Rhapson Solver
Objective: To solve a given set of Ordinary Differential equations using the Multi-Variate Newton Raphson Method. Given: The set of ODE's are given below: dy1dt=−0.04⋅y1+104⋅y2⋅y3 dy2dt=0.04⋅y1−104⋅y2⋅y3−3⋅107⋅y22 dy3dt=3⋅107⋅y22 The jacobian should be estimated numerically and not analytically.…
01 Nov 2020 03:50 AM IST
Week 5 - Literature review: ODE Stability
Objective: To review the literature about ODE and to write the python program to substantiate our results. Theory: …
20 Oct 2020 03:52 PM 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.