Challenge

Week 9 - Senstivity Analysis Assignment

Aim

  • Write a code that takes all the reactions from the GRI mechanism and calculates 10 most sensitive reactions
  • The sensitivity parameter should be with respect to the Temperature.

Theory

Sensitivity analysis is a process to get relationship between the parameters and the output of a model.

A generic ODE system is showing reaction rate as a function of temperature or species concentration.

dZ/ dt=F(Z,t,a)

Z=(T,Y1,Y2,….YK)T

Where, Z is a vector of species and temperature

First order sensitivity,

Wi,j=∂Zj / ∂ai

Where, j is the independent variable.

i is the reaction.

a is the net reaction rate multiplier (perturbation factor)

NOTE:

  1. Higher the sensitivity of the intermediary reactions, more is the influence on the output parameters.
  2. To reduce the ignition delay, the first step is to determine the sensitivity coefficient of all intermediary reaction with respect to the reaction parameter.
  3. Once this has been determined, the most sensitive reactions are observed and the reaction parameter is changed to achieve the desired results.
  4. In this study, we use Cantera module to determine the sensitivity coefficients of the intermediary reactions of CH4 combusion of GRI mechanism.
""" 
Sensitivity analysis on CH4 combustion

"""

import numpy as np  # import numpy and cantera module
import cantera as ct 
import matplotlib.pyplot as plt

gas= ct.Solution("gri30.xml") #Created gas object of Solution Method

#Initialized the temperature, pressure and molar concentrations
Temp=1500 
Pressure=ct.one_atm
gas.TPX = Temp,Pressure,{'CH4':1,'O2':2,'N2':7.52}

#created object of Ideal Gas Reactor
r = ct.IdealGasConstPressureReactor(gas, name='R1')

#created object of Reactor Network
sim = ct.ReactorNet([r])

#number of reactions in GRI mechanism
n=gas.n_reactions

#enable sensitivity wrt reactions 1 to n
for i in range(n):
	r.add_sensitivity_reaction(i)


#set relative and absolute tolerances for solution and sensitivity analysis
sim.rtol = 1e-06
sim.atol = 1e-15

sim.rtol_sensitivity= 1e-06
sim.atol_sensitivity= 1e-06

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

s_max = [0]*n

for t in np.arange(0,2e-3,5e-6):
	sim.advance(t)
	for i in range(n):
		s = sim.sensitivity('temperature',i)
		if(abs(s)>abs(s_max[i])):
			s_max[i] = s
	states.append(r.thermo.state, t=1000*t)

#sorting top 10 sensitive reactions

N=10

sen = [0]*n
sen_order= [0]*N
react_number= [0]*N

for i in range(N):
	for j in range(n):
			if(abs(np.min(s_max))>np.max(s_max)):
				sen_order[i] = np.min(s_max)
			else:
				sen_order[i] = np.max(s_max)	
			react_number[i] = s_max.index(sen_order[i])
	s_max.remove(sen_order[i])			

sens_react = [0]*N

print('Sensitivity index for the 10 most sensitive reactions')
for i in range(N):
	sens_react[i]= sim.sensitivity_parameter_name(react_number[i])
	print('s=',sen_order[i],'for reaction',sens_react[i])		

plt.figure(1)
plt.barh(sens_react,sen_order)
plt.xlabel('Sensitivity')
plt.title('Sensitivity index of 10 most sensitive reaction')

plt.figure(2)
plt.subplot(2,2,1)
plt.plot(states.t,states.T)
plt.xlabel('Time (in ms)')
plt.ylabel('Temperature (in K)')

plt.subplot(2,2,2)
plt.plot(states.t,states('CH4').X)
plt.xlabel('Time (in ms)')
plt.ylabel('Mole fraction of CH4')


plt.subplot(2,2,3)
plt.plot(states.t,states('H').X)
plt.xlabel('Time (in ms)')
plt.ylabel('Mole fraction of H')


plt.subplot(2,2,4)
plt.plot(states.t,states('OH').X)
plt.xlabel('Time (in ms)')
plt.ylabel('Mole fraction of OH')
plt.show()

Results

The output of the program shows the sensitivity coefficient for the ten most sensitive intermediary reactions.

The same is plotted using a bar graph as follows:

Observations

> The most sensitive reaction is CH3 + O2 <=> CH3O + O with a sensitivity coefficient of 16.84.

> The positive coefficient of sensitivity indicates reduce ignition delay.

> Negative sensitivity coefficient indicates increase of ignition delay.

Plot 2: Ignition delay can be determined by plotting product / reactant mole fractions vs. time

Observations

> It can be concluded that the ignition delay for the given reaction parameters is 1 ms as the concentration of fuel (CH4) decreases thereon with an increase in H and OH concentration.

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.