Project

Sensitivity Analysis wrt Temperature for GRI 3 0 Mechanism

Aim : To write a code to find 10 most sensitive reactions out of all the reactions in GRI 3.0 mechanism.

Theory:

A chemical mechanism represents all the reactions taking place in detail in order to achieve an overall global reaction. For a combustion process to take place there involves thousands of intermediate reactions. For example in the case of methane combustion it roughly has 325 intermediate reactions. All these intermediate reactions have their own individual rate constants and can be considered as a parameter affecting the system. There are many other observable parameters that a reaction can produce are temperature, pressure, mole fraction, mass fraction, species concentration, flame speed etc. Sensitivity Analysis is where we can increase the understanding of the relationships between input and output variables of that system or model.

Sensitivity Analysis:

Since there are many parameters involved in the chemistry of combustion, we need to understand the effects of each parameter impliying on the system. Hence a best technique to analyse is by performing a sensitivity analysis for the given system.

Sensitivity Annlysis for the combustion chemistry are usually associated with huge size based on the selected combustion models. This analysis helps us in understanding which are the main parameters driving the models, what and how are the direct and indirect changes of these parameters affect the combustion process etc. The main objective of this analysis is to calculate the ignition delay in the combustion and this analysis tells us which reactions affects the ignition delay.

In this case, GRI 3.0 mechanism is studied which consist of 325 reactions. We perform the sensitivity analysis of the reactions with respect to Temperature. The reaction states for all the reactions are solved and the sensitivity of the top 10 reactions are plotted in a bar graph.

Code:

\"\"\"
Sensitivity Analysis
\"\"\"

import numpy as np 
import cantera as ct
import matplotlib.pyplot as plt

gas = ct.Solution(\'gri30.xml\')

T = 1500
P = 101325

gas.TPX = T, P, {\'CH4\':1, \'O2\':2, \'N2\':7.52}


r = ct.IdealGasConstPressureReactor(gas, name = \'R1\')
sim = ct.ReactorNet([r])  

reactions = gas.reaction_equations()

#Total number of reactions in Methane combustion
n_reactions = gas.n_reactions

#Number of reactions to be considered for the sensitivity analysis
n = 10
S_max = [0]*n_reactions

#Reactions which will be added for the sensitivity analysis
for i in range (n_reactions):
	r.add_sensitivity_reaction(i)

#Relative tolerance for each variable in matrix
sim.rtol = 1e-6
#Absolute tolerance for each variable in matrix
sim.atol = 1e-15

#Relative tolerance for the sensitivity Solution
sim.rtol_sensitivity = 1e-6
#Absolute tolerance for the sensitivity Solution
sim.atol_sensitivity = 1e-6

states = ct.SolutionArray(gas, extra = \'t\')

#Putting all reactions in a array
reaction_number = np.arange(1,n_reactions+1)

#Time integration

for t in np.arange(0, 2e-3, 5e-6):
	sim.advance(t)
	states.append(r.thermo.state, t = 1000*t)

	#Storing of sensitivity values wrt to temperature
	for j in range(n_reactions):
		s = sim.sensitivity(\'temperature\', j) # j is the independent reaction

		#Equalising maximum values to normal, for printing first 10 most sensitive reactions
		if np.abs(s)>np.abs(S_max[j]):
			S_max[j] = s

S_abs = np.abs(S_max)

\"\"\"
We use sorted func() to print reactions in desending order.
\"\"\"

reactions = [a for b, a in sorted(zip(S_abs,reactions),reverse=True)]
reaction_number = [a for b, a in sorted(zip(S_abs,reaction_number),reverse=True)]
S_max = [a for b, a in sorted(zip(S_abs,S_max),reverse=True)]

max_reactions = reactions[0:n]
max_number = reaction_number[0:n]
max_sensitivity = S_max[0:n]

H_conc = states(\'H\').X
OH_conc = states(\'OH\').X
CH4_conc = states(\'CH4\').X

plt.figure(1)
plt.grid(\'on\')
plt.barh(max_reactions,max_sensitivity,color=\'blue\')
plt.gca().invert_yaxis()
plt.xlabel(\'Sensitivity\')
plt.ylabel(\'Reactions\')
plt.tight_layout()
plt.title(\'Highest Temperature Sensitive Reactions in GRI 3.0 for Methane Combustion\')

plt.figure(2)
plt.subplot(2,2,1)
plt.plot(states.t,states.T,color=\'red\')
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'Temperature\')

plt.subplot(2,2,2)
plt.plot(states.t,states(\'OH\').X,color=\'blue\')
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'OH Mole Fraction\')

plt.subplot(2,2,3)
plt.plot(states.t,states(\'H\').X,color=\'blue\')
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'H Mole Fraction\')

plt.subplot(2,2,4)
plt.plot(states.t,states(\'CH4\').X,color=\'blue\')
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'CH4 Mole Fraction\')
plt.tight_layout()

plt.show()

Plots:

The above plots represents the top 10 sensitive reactions with respect to the temperature. From the bar graph we can see there are both positive and negative sensitive coefficients obatined from the reactions. The positive sensitivity coefficients explains that as we increase the temperature the reaction rate of that particular reactants would be increased. The negative sensitivity coefficients explains that as we increase the temperature the reaction rate of that particular reactants would be decreased.

The above graph shows us evolution of temperature and mole fractions of species with respect to time.

  • The initial temperature of the mixture was set to 1500 K and at the end of the reaction it reaches to around 2750 K.
  • The mole fractions of OH and H are being increased and are stabilised after attaining an equilibirum state. Similarly when we look into the species profile of CH4 initially it is high and at the end of the timestep is almost zero. At the beginning of reactions we can see the CH4 is high as combustion is not started and as it progress till the end all the CH4 are consumed and the products such as OH, H and other species are formed.
  • We can see a sudden spike roughly around 1.2 ms in all the 4 plots as this is the ignition delay beyond which the mixture is ignited and combustion occurs.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.